Standard

R

rob p

I need some suggestions on a simple form.

Field One: Box number - no duplicates - starts at one - I may want to add a
box number or pull up an old box numbers If I put in a old box number, I
want that record to fill the fields. If I put in a new number, I want the
other fields clear. Is there a way to do this without autonumbering?

Related, for a simple form are there any standards for button's used? Like
OK, Delete, Close??
 
T

tina

so you want to find an existing record with that box number; and if it
doesn't exist, then you want to create a new record using that box number.
right?

suggest you add an unbound textbox to the form header section of your form;
i'll call it txtBoxNumber. in the textbox's AfterUpdate event procedure, add
the following, as

Private Sub txtBoxNumber_AfterUpdate()

On Error Resume Next

Me.Recordset.FindFirst "MyBoxNumber = " & Me!txtBoxNumber
If Me.Recordset.NoMatch Then
DoCmd.RunCommand acCmdRecordsGoToNew
Me!MyBoxNumber = Me!txtBoxNumber
Me!txtBoxNumber = Null
Me!NextControl.SetFocus
End If

End Sub

"txtBoxNumber" is the unbound textbox, as noted above. "MyBoxNumber" is the
control in the form that's bound to the box number field in the table.
"NextControl" is the next control in the form's tab order, after
MyBoxNumber. you'll need to substitute the correct control names, of course.

hth
 
Top