Form & where Condition Macro



I am using 2007 access (OS=XP). I designed a form in my database that works
as a homepage. It basically pulls summary of everything about a patient from
various tables. The homepage has multiple sub-forms and tabs that leads to
other subforms all joined by PatientID. Each time a patient comes in for a
visit, the homepage will act as a summary for that date of visit. So far so
good! However, when I created the search for this homepage, my where
condition is (="[PatientID]=" & [PatientID]).
Now I want the homepage to only open the Date of Visit selected. I tried to
change my where condition to (="[DateofVisit]=" & [DateofVisit]) but that
doesn’t work. If I leave my PatientID condition then I can’t get it to open
only the selected date of visit.
I created a query where I want to open a form only based on date of visit.
But when I click on a specific date of visit listed on my query subform, it
always open the form for the right patient but the wrong date of visit. How
can I fix this? Is there anyway I can have the patientID and DateofVisit
under condition? Please help.

Allen Browne

So, your main form (homepage) is bound to a table/query, and your goal is to
have a text box where the user can enter a number, and the form jumps to
display that record?

If that's the idea, the navigation text box needs to be unbound, and needs
to have a different name than the PatientID field. Let's say we set up its
properties like this:
Name txtGoTo
Format General Number
Control Source {left blank}
After Update [Event Procedure]

Now you click the Build button (...) beside the After Update property.
Access opens the code window. You enter code as shown here:
While that article talks about using a combo rather than a text box, the
code is the same (just replacing cboMoveTo with txtGoTo.)

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