Variable

  • Thread starter Thread starter williamr
  • Start date Start date
W

williamr

I do a filter using a form that returns a record using the PK. I want to
create a Word doc with the info from the filtered query. I Dimmed some
variables to test, one called xAccountNo and said in the code xAccountNo =
AccountNo, but nothing happens, it does not show up anywhere. Could someone
show me what the code should look like?

Thanks in Advance
 
Variables don't show up anywhere unless you assign them to something visible.
What were you expecting?
 
After the filter and I have one record, I'm trying to assign the information
in the query to a variable name.
 
Sorry, I don't get the whole picture.
Assigning a query field's value to a variable is not a big deal, but I need
a lot more detail, please.
 
I have a form with a drop down, it lets the user select which record they
want to select. After selecting the record they press "Continue" and the
query filters out all the records execpt that one, so in the query there is
only one record. Now I want to put the information from that record on a
Word document, then print it. Is this the wrong way to do this??

Thanks
 
I am not familiar with using the Word object model, so I guess I may not be
the best person to answer your question; however, if the document is totally
created in Access, and just presented as a word document, you may explore
using the OutputTo method.
 
OK but how do I capture the info in the query? There is a field in the query
named 'Address'. I want to pass that info to a variable so I created a
variable named 'Xaddress', I then entered a line of code that said "Xaddress
= [forms]![frmreleaseletter]![address], then the line of code 'msgbox
("Address is ") & Xaddress. I get nothing, not even the msgbox.
 
Xaddress = [forms]![frmreleaseletter]![address]
MsgBox "(Address Is) " & Xaddress

Should do it. But, where did you put the code and how do you cause it to
execute?
--
Dave Hargis, Microsoft Access MVP


williamr said:
OK but how do I capture the info in the query? There is a field in the query
named 'Address'. I want to pass that info to a variable so I created a
variable named 'Xaddress', I then entered a line of code that said "Xaddress
= [forms]![frmreleaseletter]![address], then the line of code 'msgbox
("Address is ") & Xaddress. I get nothing, not even the msgbox.

Klatuu said:
I am not familiar with using the Word object model, so I guess I may not be
the best person to answer your question; however, if the document is totally
created in Access, and just presented as a word document, you may explore
using the OutputTo method.
 
I have a Cmd button with the following code

Private Sub cmdShowReleaseInfo_Click()
Dim Xdeveloper As String
DoCmd.OpenQuery "ReleaseLetterQry", , acReadOnly
DoCmd.ApplyFilter , "[offsites!VaultId] = " &
[Forms]![frmreleaseletter]![Text4]

Xdeveloper = [Forms]![frmreleaseletter]![Developer]
MsgBox ("Developer = ") & Xdeveloper

I get nothing

Thanks

Klatuu said:
Xaddress = [forms]![frmreleaseletter]![address]
MsgBox "(Address Is) " & Xaddress

Should do it. But, where did you put the code and how do you cause it to
execute?
--
Dave Hargis, Microsoft Access MVP


williamr said:
OK but how do I capture the info in the query? There is a field in the query
named 'Address'. I want to pass that info to a variable so I created a
variable named 'Xaddress', I then entered a line of code that said "Xaddress
= [forms]![frmreleaseletter]![address], then the line of code 'msgbox
("Address is ") & Xaddress. I get nothing, not even the msgbox.

Klatuu said:
I am not familiar with using the Word object model, so I guess I may not be
the best person to answer your question; however, if the document is totally
created in Access, and just presented as a word document, you may explore
using the OutputTo method.
--
Dave Hargis, Microsoft Access MVP


:

I have a form with a drop down, it lets the user select which record they
want to select. After selecting the record they press "Continue" and the
query filters out all the records execpt that one, so in the query there is
only one record. Now I want to put the information from that record on a
Word document, then print it. Is this the wrong way to do this??

Thanks

:

Sorry, I don't get the whole picture.
Assigning a query field's value to a variable is not a big deal, but I need
a lot more detail, please.
--
Dave Hargis, Microsoft Access MVP


:

After the filter and I have one record, I'm trying to assign the information
in the query to a variable name.

:

Variables don't show up anywhere unless you assign them to something visible.
What were you expecting?
--
Dave Hargis, Microsoft Access MVP


:

I do a filter using a form that returns a record using the PK. I want to
create a Word doc with the info from the filtered query. I Dimmed some
variables to test, one called xAccountNo and said in the code xAccountNo =
AccountNo, but nothing happens, it does not show up anywhere. Could someone
show me what the code should look like?

Thanks in Advance
 
You need to remove the ApplyFilter and modify your query to include it in a
WHERE clause.

If offsites!VaultId is numeric:
WHERE "[offsites!VaultId] = " & [Forms]![frmreleaseletter]![Text4]

If it is text:
WHERE "[offsites!VaultId] = '" & [Forms]![frmreleaseletter]![Text4] "'"
--
Dave Hargis, Microsoft Access MVP


williamr said:
I have a Cmd button with the following code

Private Sub cmdShowReleaseInfo_Click()
Dim Xdeveloper As String
DoCmd.OpenQuery "ReleaseLetterQry", , acReadOnly
DoCmd.ApplyFilter , "[offsites!VaultId] = " &
[Forms]![frmreleaseletter]![Text4]

Xdeveloper = [Forms]![frmreleaseletter]![Developer]
MsgBox ("Developer = ") & Xdeveloper

I get nothing

Thanks

Klatuu said:
Xaddress = [forms]![frmreleaseletter]![address]
MsgBox "(Address Is) " & Xaddress

Should do it. But, where did you put the code and how do you cause it to
execute?
--
Dave Hargis, Microsoft Access MVP


williamr said:
OK but how do I capture the info in the query? There is a field in the query
named 'Address'. I want to pass that info to a variable so I created a
variable named 'Xaddress', I then entered a line of code that said "Xaddress
= [forms]![frmreleaseletter]![address], then the line of code 'msgbox
("Address is ") & Xaddress. I get nothing, not even the msgbox.

:

I am not familiar with using the Word object model, so I guess I may not be
the best person to answer your question; however, if the document is totally
created in Access, and just presented as a word document, you may explore
using the OutputTo method.
--
Dave Hargis, Microsoft Access MVP


:

I have a form with a drop down, it lets the user select which record they
want to select. After selecting the record they press "Continue" and the
query filters out all the records execpt that one, so in the query there is
only one record. Now I want to put the information from that record on a
Word document, then print it. Is this the wrong way to do this??

Thanks

:

Sorry, I don't get the whole picture.
Assigning a query field's value to a variable is not a big deal, but I need
a lot more detail, please.
--
Dave Hargis, Microsoft Access MVP


:

After the filter and I have one record, I'm trying to assign the information
in the query to a variable name.

:

Variables don't show up anywhere unless you assign them to something visible.
What were you expecting?
--
Dave Hargis, Microsoft Access MVP


:

I do a filter using a form that returns a record using the PK. I want to
create a Word doc with the info from the filtered query. I Dimmed some
variables to test, one called xAccountNo and said in the code xAccountNo =
AccountNo, but nothing happens, it does not show up anywhere. Could someone
show me what the code should look like?

Thanks in Advance
 
I don't understand! Are you saying the "where" should be in the query? If
so, how do I use the form to "Select" the record I need??

Thanks

Klatuu said:
You need to remove the ApplyFilter and modify your query to include it in a
WHERE clause.

If offsites!VaultId is numeric:
WHERE "[offsites!VaultId] = " & [Forms]![frmreleaseletter]![Text4]

If it is text:
WHERE "[offsites!VaultId] = '" & [Forms]![frmreleaseletter]![Text4] "'"
--
Dave Hargis, Microsoft Access MVP


williamr said:
I have a Cmd button with the following code

Private Sub cmdShowReleaseInfo_Click()
Dim Xdeveloper As String
DoCmd.OpenQuery "ReleaseLetterQry", , acReadOnly
DoCmd.ApplyFilter , "[offsites!VaultId] = " &
[Forms]![frmreleaseletter]![Text4]

Xdeveloper = [Forms]![frmreleaseletter]![Developer]
MsgBox ("Developer = ") & Xdeveloper

I get nothing

Thanks

Klatuu said:
Xaddress = [forms]![frmreleaseletter]![address]
MsgBox "(Address Is) " & Xaddress

Should do it. But, where did you put the code and how do you cause it to
execute?
--
Dave Hargis, Microsoft Access MVP


:

OK but how do I capture the info in the query? There is a field in the query
named 'Address'. I want to pass that info to a variable so I created a
variable named 'Xaddress', I then entered a line of code that said "Xaddress
= [forms]![frmreleaseletter]![address], then the line of code 'msgbox
("Address is ") & Xaddress. I get nothing, not even the msgbox.

:

I am not familiar with using the Word object model, so I guess I may not be
the best person to answer your question; however, if the document is totally
created in Access, and just presented as a word document, you may explore
using the OutputTo method.
--
Dave Hargis, Microsoft Access MVP


:

I have a form with a drop down, it lets the user select which record they
want to select. After selecting the record they press "Continue" and the
query filters out all the records execpt that one, so in the query there is
only one record. Now I want to put the information from that record on a
Word document, then print it. Is this the wrong way to do this??

Thanks

:

Sorry, I don't get the whole picture.
Assigning a query field's value to a variable is not a big deal, but I need
a lot more detail, please.
--
Dave Hargis, Microsoft Access MVP


:

After the filter and I have one record, I'm trying to assign the information
in the query to a variable name.

:

Variables don't show up anywhere unless you assign them to something visible.
What were you expecting?
--
Dave Hargis, Microsoft Access MVP


:

I do a filter using a form that returns a record using the PK. I want to
create a Word doc with the info from the filtered query. I Dimmed some
variables to test, one called xAccountNo and said in the code xAccountNo =
AccountNo, but nothing happens, it does not show up anywhere. Could someone
show me what the code should look like?

Thanks in Advance
 
Yes, the Where should be in the query.
Reread my previous post. It shows how the query's Where clause should be
contructed. The value in Text4 is what will be used for the search.
--
Dave Hargis, Microsoft Access MVP


williamr said:
I don't understand! Are you saying the "where" should be in the query? If
so, how do I use the form to "Select" the record I need??

Thanks

Klatuu said:
You need to remove the ApplyFilter and modify your query to include it in a
WHERE clause.

If offsites!VaultId is numeric:
WHERE "[offsites!VaultId] = " & [Forms]![frmreleaseletter]![Text4]

If it is text:
WHERE "[offsites!VaultId] = '" & [Forms]![frmreleaseletter]![Text4] "'"
--
Dave Hargis, Microsoft Access MVP


williamr said:
I have a Cmd button with the following code

Private Sub cmdShowReleaseInfo_Click()
Dim Xdeveloper As String
DoCmd.OpenQuery "ReleaseLetterQry", , acReadOnly
DoCmd.ApplyFilter , "[offsites!VaultId] = " &
[Forms]![frmreleaseletter]![Text4]

Xdeveloper = [Forms]![frmreleaseletter]![Developer]
MsgBox ("Developer = ") & Xdeveloper

I get nothing

Thanks

:

Xaddress = [forms]![frmreleaseletter]![address]
MsgBox "(Address Is) " & Xaddress

Should do it. But, where did you put the code and how do you cause it to
execute?
--
Dave Hargis, Microsoft Access MVP


:

OK but how do I capture the info in the query? There is a field in the query
named 'Address'. I want to pass that info to a variable so I created a
variable named 'Xaddress', I then entered a line of code that said "Xaddress
= [forms]![frmreleaseletter]![address], then the line of code 'msgbox
("Address is ") & Xaddress. I get nothing, not even the msgbox.

:

I am not familiar with using the Word object model, so I guess I may not be
the best person to answer your question; however, if the document is totally
created in Access, and just presented as a word document, you may explore
using the OutputTo method.
--
Dave Hargis, Microsoft Access MVP


:

I have a form with a drop down, it lets the user select which record they
want to select. After selecting the record they press "Continue" and the
query filters out all the records execpt that one, so in the query there is
only one record. Now I want to put the information from that record on a
Word document, then print it. Is this the wrong way to do this??

Thanks

:

Sorry, I don't get the whole picture.
Assigning a query field's value to a variable is not a big deal, but I need
a lot more detail, please.
--
Dave Hargis, Microsoft Access MVP


:

After the filter and I have one record, I'm trying to assign the information
in the query to a variable name.

:

Variables don't show up anywhere unless you assign them to something visible.
What were you expecting?
--
Dave Hargis, Microsoft Access MVP


:

I do a filter using a form that returns a record using the PK. I want to
create a Word doc with the info from the filtered query. I Dimmed some
variables to test, one called xAccountNo and said in the code xAccountNo =
AccountNo, but nothing happens, it does not show up anywhere. Could someone
show me what the code should look like?

Thanks in Advance
 
Back
Top