continuous form with command button on each record to open another form

rodrigoturbina

Registered User.
Local time
Today, 14:35
Joined
Jul 30, 2014
Messages
29
Hi everyone this is Rod, I have a continuous form in which I put a command button for each record called "detail". I would like to click on the "detail" button and make it open another form containing all (and only) the info on this record.

At first I refused to use an "id" to link both forms, but finally I added the "id" in the table... however still does not work.

continuous form: "04 - GASTOS_BUSQUEDA"
id field on continuous form: "Gastid"

pop-up (details) form: "GASTOS_EDITAR"
id on pop-up (details) form: "editar_id"

This is what I have tried on the "click" properties of the "details" button field (called "btn_editgs"):

1)
DoCmd.OpenForm "GASTOS_EDITAR", acNormal, , "[editar_id] = " & Me.Gastid

2)
DoCmd.OpenForm "GASTOS_EDITAR", , , "[editar_id]=" & Me.Gastid

3)
stLinkCriteria = "[editar_id]=" & Me![Gastid]
DoCmd.OpenForm "GASTOS_EDITAR", , , stLinkCriteria

4)
Private Sub btn_editgs_Click()
On Error GoTo btn_editgs_Click_Err
Dim strWhere As String
strWhere = "[editar_id] = " & Me.Gastid
DoCmd.OpenForm "GASTOS_EDITAR", , , strWhere
btn_editgs_Click_Exit:
Exit Sub
btn_editgs_Click_Err:
MsgBox Error$
Resume btn_editgs_Click_Exit
End Sub



Thanks in advance!!!
 
Thank you for your response, but I am afraid still does not work.
I set it up like this:

DoCmd.OpenForm "GASTOS_EDITAR", , , "editar_id = " & Me.Gastid

it asks me to enter parameter value for field "editar_id", and no matter if I enter the number manually, it opens the form but all blank, no fields in it.

If I choose "cancel" and click on "debug", then it shows the code line and when I stand over the fields it shows that the VBA is "picking" the ID values, since it shows "3" (which is the ID of the record I want to open in the new form) over both fields: "editar_id" and over "Me.Gastid".

I wonder what am I doing wrong...
 
The parameter prompt is Access telling you it can't find something. Are you sure it's an underscore rather than a space?
 
I am sure I did, just in case:

continuous form: "04 - GASTOS_BUSQUEDA"
con form id: "Gastid"
button that triggers the other form open: "btn_editgs"

new form: "GASTOS_EDITAR"
new form id field: "editar_id"

so the code should be fine as is:

DoCmd.OpenForm "GASTOS_EDITAR", , , "editar_id = " & Me.Gastid

still aint working...
 
If you're still getting a parameter prompt, the implication is that editar_id is not a field in the recordsource of the form being opened. Can you post the db here?
 
Paul, you pointed me the answer: it happened that the second form (GASTOS_EDITAR), in the ID field, I had changed its name to "editar_id"; but the control origin pointed to the real name in the table: "ID_GASTO". So I changed it back to "ID_GASTO" and it worked...

thanks so much for the answer... this is your second resolution for me today, so I owe you 2 beers ;)
 
Happy to help! And I'll collect on those beers! :p
 
I wanted to drop in a thanks, too. I was having a similar problem, and the answers here finally made it click.

YAY! Search function!
 

Users who are viewing this thread

Back
Top Bottom