button to open a form

Jere

Registered User.
Local time
Today, 05:50
Joined
Oct 31, 2012
Messages
12
Been a while since I've posted here. I've appreciated the help I've received, and the knowledge here. (:

I'm not sure how to correctly ask the question, or convey the question, so I'll just describe what I'm trying to figure out.

I have a form that uses a query to filter out records to show basic info of records (each one has a unique ID) only pertaining to today that are listed one under the other using a whole row. What I'm looking for is a way to design a button for these filtered records within that row that when clicked, will open up a new form that I've already designed for just that ID.

I've tried searching online, but like I said above, I can't seem to word the question right so not getting the results I need.
 
You can open another form like

DoCmd.OpenForm, "FormNameHere", WhereCondition:="[IDFieldNameHere]=" & Me.MyIDField

So, if your control on the form you are currently on is called MyIDField, and is numeric, the code above will open to the record with that ID in the other form.

If you have a text field, not numeric, it would require quotes (I use Chr(34)).

DoCmd.OpenForm, "FormNameHere", WhereCondition:="[IDFieldNameHere]=" & Chr(34) & Me.MyIDField & Chr(34)

And if it is a date it needs octothorpes (#).

DoCmd.OpenForm, "FormNameHere", WhereCondition:="[IDFieldNameHere]=#" & Me.MyIDField & "#"

Be sure to change IDFieldNameHere to the applicable ID field name in the form you are trying to open from the button.
 
Back to this topic, can I use the same field for a 2nd button? My testing says no, but I feel like I'm missing something somewhere.

When I enter the code in, it still asks for the ID that I'm using as my Autonumber for each record. The first button works just fine, but I ultimately ended up using the "create button" to link my ID for the current form to the ID of the form I wanted to open. I tried mimicking this with the new button, but the ID doesn't show up in the Main form the button is on, and editing the embedded macro just doesn't fix it either.
 
Last edited:
Could you give a little bit more detail?
 
based off the information above with the summary form page, i have one button that opens another form using the Autonumber that I've labeled as TripID to only show that record in that form. This button works just fine, as I used the ability to create a button, and linked TripID from the summary form with TripID for the 2nd form.

I'm trying to recreate the process by making a 2nd button that links to a separate form from the summary form, still using TripID off of the summary form, but it's not listed. I then tried to use the commands given above as well by using the "code builder" in the events for button click. Then testing the code out, it still throws up asking for the TripID for the form I'm trying to open up.
 
If it throws up the input box then it means it can't find what you've referenced and you have either referenced the wrong field name or misspelled it.
 

Users who are viewing this thread

Back
Top Bottom