Comparing text and number fields

D

Dudley

I have AutoNumber field EnvelopeNumber and text field AuthenticationCode,
with the default for AuthenticationCode equalling EnvelopeNumber. In Allen
Browne's code to duplicate records, I have code to update the
AuthenticationCode if it equals the AutoNumber, but accept it if the user has
entered his own code.

If Me.AuthenticationCode = Me.EnvelopeNumber Then
!AuthenticationCode = !EnvelopeNumber
Else
!AuthenticationCode = Me.AuthenticationCode
End If

This always copies the AuthenticationCode, I assume because Access does not
recognise that a number field can equal a text field.

Thanks for any help.
Dudley
 
D

Dudley

Thanks very much. This works fine so long as the AuthenticationCode is all
numbers, but it can include letters and then it gives a type mismatch. Is
there a way round this?

Thanks
Dudley
 
J

Jeanette Cunningham

You could convert them both to a string before you compare them.

If CStr(Me.AuthenticationCode) = CStr(Me.EnvelopeNumber) Then


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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