Access web form

schlossero

New member
Local time
Today, 05:05
Joined
Feb 23, 2015
Messages
1
I want to use a variable from a form to a query as a criterion. but how?
 
This appears to be your first post, and you have not given enough information to get a good answer. Is your front end an Access form or a web page? If it's an Access form, you should know there are modules behind each form where you can write code. And each box on the form has events associated with it. The big picture answer to your question would be, in the after_update event of the field in question, you assign the value of that field to a variable and incorporate it into an SQL string to get the record associated with the value. Something like this.
Private Sub SelectPerson After_Update
dim PID as Long
dim SQL as String
if me.SelectPerson.value > 0 then
PID = me.SelectPerson.value
SQL = "Select * FROM tblPeople WHERE (tblPeople.PeopleID=" & PID & ");"
me.recordsource = SQL
end if
End Sub
If you don't know how to get to modules, open the form in design mode, and select properties for the text box in question. Then click on the Other tab, and set the "Has Module" line, fourth from the bottom, to Yes. Then click on the Events tab, locate After Update and double click the box. It should say "Event Procedure". Now click on the ellipse button, the three periods on that line, and the Visual Basic code writing area will open on the after update event for the selected field on the form. Copy the code I gave you, changing the names accordingly and it should work.
Hope that helps.
 

Users who are viewing this thread

Back
Top Bottom