Parameter question

B

Brenda

I am scanning a value into a field on a form via a parameter box. There will
be occasions where a particular item had been previously scanned. In such
instances, I'd like the form to show the previously entered data in the form
and allow me to update another one of the fields on that particular form. How
might I achieve this?

In the instance where I scan a new value, upon enter, I'd like a new
parameter box to appear so I might enter the next record.

Thanks for you assistance.
 
J

John W. Vinson

I am scanning a value into a field on a form via a parameter box. There will
be occasions where a particular item had been previously scanned. In such
instances, I'd like the form to show the previously entered data in the form
and allow me to update another one of the fields on that particular form. How
might I achieve this?

In the instance where I scan a new value, upon enter, I'd like a new
parameter box to appear so I might enter the next record.

Thanks for you assistance.

You can put some VBA code in the AfterUpdate event of the textbox to check
whether the entered (scanned) value already exists. E.g.

Private Sub txtMyTextbox_AfterUpdate()
Dim iAns As Integer
Dim rs As DAO.Recordset
If IsNull(DLookUp("[fieldname]", "[tablename]", _
"[fieldname] = '" & Me!txtMyTextbox & "'") Then
' do nothing, this is a new value
Else
' existing record, navigate to it
iAns = MsgBox("This value already in, move to that record?", vbYesNo)
If iAns = vbYes Then
Me.Undo ' erase the current new entry
Set rs = Me.RecordsetClone
rs.FindFirst "[fieldname] = '" & Me!txtMyTextbox & "'"
If rs.NoMatch Then
MsgBox "OOPS! Not there after all!"
Else
Me.Bookmark = rs.Bookmark ' move to the record
End If
Else
<do something else appropriate>
End If
End If
End Sub
 

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