Command button error

S

Stephen D Cook

I have a form with 3 text boxes, 2 command buttons and a subform.

The first text box is for the serial number, the other 2 text boxes
are for data associated with the serial number.

The 2 command buttons are for Add and History.

The subform is to display the history, based on the serial number and
is linked to a query which uses the line, [Forms]![frmSN]![txtSN] for
criteria.

The Add command button has DoCmd.GoToRecord , , ACNewRec to add the
new record.

The History button has
DoCmd.ApplyFilter, "[SerialNumber] = Forms!frmSN!txtSN"
If Me.Dirty Then
Me.Dirty = False
End If

The history button works fine at displaying the history in the
subform, and the Add button works fine when adding a new record.

The problem is when I use the History button, then the Add button.
When it should add a record to the table, instead it is updating the
first instance of the Serial Number with the new information.

How do I get the Add button to always add a new record?
 
S

Svetlana

You need to remove your filter first before you add a new record.
Try something like this
If Me.FilterOn=True Then
Me.FilterOn=False
End If
DoCmd.GoToRecord , , ACNewRec
 

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