find existing record

  • Thread starter Thread starter David Whitaker
  • Start date Start date
D

David Whitaker

how would you go about searching for an existing item using a textbox's
before update event?
 
How complicated this gets depends on what exactly you're trying to do.
However, just to see if the value already exists, you could use DCount.

If DCount("[FieldName]", "[TableName]", "[FieldName]=" &
Me.txtNameOfTextbox.Text) >= 1 Then

The above assumes a number value, if the value is text:

If DCount("[FieldName]", "[TableName]", "[FieldName]=""" &
Me.txtNameOfTextbox.Text & """") >= 1 Then
 
Thats what I needed

Wayne Morgan said:
How complicated this gets depends on what exactly you're trying to do.
However, just to see if the value already exists, you could use DCount.

If DCount("[FieldName]", "[TableName]", "[FieldName]=" &
Me.txtNameOfTextbox.Text) >= 1 Then

The above assumes a number value, if the value is text:

If DCount("[FieldName]", "[TableName]", "[FieldName]=""" &
Me.txtNameOfTextbox.Text & """") >= 1 Then

--
Wayne Morgan
MS Access MVP


David Whitaker said:
how would you go about searching for an existing item using a textbox's
before update event?
 
Back
Top