Something simple

G

Guest

Whenever I run this code Access asks me to enter stImproved. When I type in
Improved and hit enter the rest of the code works fine and the correct
records are retrieved. I thought by putting stImproved = "Improved" that
this was already substantiated. what am I missing.

Dim stDocName As String
Dim stLinkCriteria As String
Dim stImproved As String

stDocName = "TblImproved"

stLinkCriteria = stLinkCriteria & _
" AND TblComparable!ImprovedVacant = stImproved"
 
J

John Vinson

Whenever I run this code Access asks me to enter stImproved. When I type in
Improved and hit enter the rest of the code works fine and the correct
records are retrieved. I thought by putting stImproved = "Improved" that
this was already substantiated. what am I missing.

Dim stDocName As String
Dim stLinkCriteria As String
Dim stImproved As String

stDocName = "TblImproved"

stLinkCriteria = stLinkCriteria & _
" AND TblComparable!ImprovedVacant = stImproved"

You're searching (with invalid syntax) for records with the text
string "stImproved" - the NAME of the field, not its value - in the
field ImprovedVacant. You're also defining a string variable
stLinkCriteria but not using it. Two more changes: one, use the
syntactically required quotemarks; and two, concatenate the value of
the variable, not its name.

You do need to assign a value to stImproved within this Sub. Try:

Dim stDocName As String
Dim stLinkCriteria As String
Dim stImproved As String

stDocName = "TblImproved"
stImproved = "Improved"
stLinkCriteria = "[tblComparable].[ImprovedVacant] = '" & _
stImproved & "'"

Then use stLinkCriteria in your OpenForm or OpenReport call.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
G

Guest

Thanks for the help. I only posted a portion of the code though,
stLinkCriteria is used later.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top