trouble using button to open new form to add new record

D

DH

I've got two tables, a Distribution table and a Transaction table, with a one
to many relationship between then, one distribution to many transactions,
pk_distrib_id to fk_distrb_id.

I have a distribution form which displays current information, and a
new_transaction form which I want to use only to add new transactions
associated with the distribution displayed.

How do I add a button that opens up the new_transaction form to a new
record, but fills the fk_distrib_id field in the new record with the
pk_distrib_id of the distribution currently displayed?

I can add a button that opens up the new_transaction form, but it displays
all the records (I only want it to show a new record for entry). I tried
setting DataEntry to Yes on that form, but then the new record is completely
empty (someone would have to type in the fk_distrib_id - not good).
 
D

DH

Just as a note, I tried using the following adapted code in the onclick
event of the button in the distribution form:

Private Sub Add_Transaction_Click()
DoCmd.OpenForm "frm_Transaction_Log_New", , , "FK_distribution_id=" &
Me.PK_Distribution_ID, , acFormAdd
DoCmd.GoToRecord , , acNewRec
Me.Requery
End Sub

It didn't work, and I'm really not a coder, so all help is gratefully
appreciated.
 

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

Top