Having trouble with filter on load

carahorse

Registered User.
Local time
Today, 14:12
Joined
Apr 1, 2013
Messages
36
This has got to be easy but I have tried lots of ways to get it done...:confused:

I have two forms, "SPBookings" field[ID], and "Find Bookings Form" with field (lookup field) [Booking ID] and my macro, on button click located on SP Bookings. This does fine to open and filter records. The macro has a filter on load event
Find Bookings form, Form, , ="[BookingID]=" & [ID], , Normal

The SPBookings form field [ID] equals [Booking ID] when I open the "Find Bookings Form"

I would like to click on a button on my main nav form, to open the SP Bookings form, and then open and display records on the "Find Bookings Form" related only to the SPBooking [ID] Field.
DoCmd.OpenForm "SPBookings"

Then I tried

DoCmd.OpenForm "Find Bookings Form", , , "BookingID" = "ID"

and many other combinations but no luck Thanks in advance!

oh and both fields are number fields long integer if that helps
 
What tables do you have? What are you doing in business (NON-ACCESS) terms?
Usually, a description of the business involved will help the reader understand you situation.

If your ID is numeric, you do NOT need to enclose it in quotes.
You might try
DoCmd.OpenForm "Find Bookings Form", , , "BookingID = ID"
 
Surely you mean
Code:
DoCmd.OpenForm "Find Bookings Form", , , "BookingID = " & [ID]
 
Yes. Thanks David
 
Thanks guys, I tried this:

DoCmd.OpenForm "Find Bookings Form", , , "BookingID = " & [ID]

and got:
Run Time error "2465":
Bookings can't find the field "l" referred to in your expression

and then I Tried
DoCmd.OpenForm "Find Bookings Form", , , "BookingID = ID"

and got a message box asking for a parameter value and when I put in the ID number in it did filter the correct records on the Find Bookings Form

Question now how to get it to filter correctly without a message box popping up

--and to answer the question, we are using access for a reservation tracking program for our non profit for kids and horses- we have Three Tables SPBookings,(which tracks start date time, end date time, and a unique booking ID) SPDetails (which has Booking ID, Contact ID and has other needed details) SPContacts (Which holds customer information), backed up to sharepoint so we can all view each others work. MS Access is just a relatively easy way for a beginner to put together forms ect-unfortunatly sharepoint with my beginner level forces use of lookups...pain in the buns!) And of course we base our forms on queries
 
Last edited:
I can see no reason error 2465 would come up with the code I gave you. Can you post your ACTUAL code that triggered that error? Is the field actually called [ID] for example?

jdraw's version works only because it is ignoring that code entirely and asking for a parameter in its place. I bet the name of the parameter was [BookingID = ID] wasn't it?
 
The following code shows an error, the button is located on an unbound form, but I wouldn't think that would make a difference since the Form "SPBookings" with the ctl "ID" is being opened first
Private Sub Command0_Click()
DoCmd.OpenForm "SPBookings"
DoCmd.OpenForm "Find Bookings Form", , , "BookingID = " & [ID]
End Sub


yep is odd, since the macro works just fine if "Find Bookings Form" is opened with a button located on the "SPBookings Form"

https://plus.google.com/u/0/

couple of screen shots at this link
 
You have to tell Access where to look for that unbound field! [ID] could mean anything... probably it should say something like "BookingID = " & Forms!SPBookings!ID - consult the Expression Builder for an exact reference to that form field.

...although, I'm a little confused why your search form is called SPBookings and the form it pulls up afterward is called [Find Bookings Form]. Is that accurate?
 
HA! THANK YOU SO MUCH! and I tried that one before too, and the syntax must not have been correct! I am so excited cause I learned something new =) see teach us newun's to fish and hopefully we can help other folks

this is the code that works in case anyone else needs to know

Private Sub Command0_Click()
DoCmd.OpenForm "SPBookings"
DoCmd.OpenForm "Find Bookings Form", , , "BookingID = " & Forms!SPBookings!ID
End Sub

lovely, this will help new users a lot

ooh I can even have previous record and next record buttons now that will make the forms ID's match up =)!
 

Users who are viewing this thread

Back
Top Bottom