search for entries and save new record

G

Guest

I have a continuous form that should accomplish two goals: search for records
relating to a project (via an unbound combo box) and save a new record in a
table for the project selected in the combo box.

The form is bound to the table so that the user can select a value in the
combo box and view the associated records. The user can also enter a new
record at the bottom of the continuous form. My question is: How do I save
the Project_ID value in the unbound combo box in the Project_ID field of the
table for the newly inserted record?

Thanks,
Melanie
 
G

Guest

Hi Melanie,

In the form before update event, you need to check if the record is a new
record. if it is, then get the value from the combo box and put it in the
project id field.

The code looks like this

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.Project_ID = Me.Combo13
End If
End Sub


Change Me.Combo13 to the name of your combo box. If the column count of the
combo box is >1, then you would have to use

Me.Project_ID = Me.Combo13.Column(1)

Column(1) refers to the second column in the row source of the combo box
(column count is zero based).

HTH
 

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