Opening a form and poulating fields from another table

C

Cyberwolf

I have a form that I would like to ake information from and populate certain
fields in a new record in another form by pressing a button. I first attempt
is pretty clumsy and doesn't work at all. I opens the form and runs the
query, but does not poulate any fields. It errors out on the first line where
I try to populate the field.

I get the Object required error. Here is my code:

Private Sub butAddCB_Click()
'On Error GoTo Err_butAddCB_Click

DoCmd.OpenForm "frm:Chargebacks", acNormal, , , acFormAdd, acWindowNormal
DoCmd.GoToRecord , "frm:Chargebacks", acNewRec
DoCmd.OpenQuery "qry:AddCB", acViewNormal, acReadOnly

Forms![frm:Chargebacks]![Line Number] = queries![qry:ADDCB]![LINE#]
Forms![frm:Chargebacks]![Store] = queries![qry:ADDCB]![Store]
Forms![frm:Chargebacks]![Amount] = queries![qry:ADDCB]![Amount]
Forms![frm:Chargebacks]![Claim Number] = queries![qry:ADDCB]![REF#]

Exit_butAddCB_Click:
Exit Sub

Err_butAddCB_Click:
MsgBox Err.Description
Resume Exit_butAddCB_Click

End Sub

Pretty bad I admit, but I just can't figure how to do it.

TIA
 
Top