General discussion

Locked

Access 2000 - message boxes

By sej ·
The first field in my DB is a unique number, with no duplicates allowed (set in props.). But, the message that says "the record cant be saved as it will create duplicates", appears when the user has filled in 50 or more fields. Therefore I would like to attach a message box to the number field in question, to say "If [field]= *the same as a previous record* then flag a message box, but as you can see i'm unsure of the syntax!
Can anyone help me please...

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Access 2000 - message boxes

by john_wills In reply to Access 2000 - message bo ...

Attach a test in Visual Basic by using the On Lost Focus event under the Events tab of the property box for the first field. In the subroutine so created, write something like
if Dcount("[FirstField]","TableName", "[FirstField]='" & me.FirstField &"'")> 0 _
then
msgbox(whatever)
endif

Collapse -

Access 2000 - message boxes

by sej In reply to Access 2000 - message bo ...

I have typed this into the onlost focus event sub. If DCount("[lab no]", "data", "[lab no]='" & Me.[lab no] & "'") > 0 _
Then
MsgBox (whatever) and got a runtime error 3464 data type mismatch in criteria expression ???

Collapse -

Access 2000 - message boxes

by john_wills In reply to Access 2000 - message bo ...

What I gave you last time was under the assumption that FirstField was a text. If it's a number, do the same without the apostrophes(or the quotation mark pair surrounding the second apostrophe).

Collapse -

Access 2000 - message boxes

by sej In reply to Access 2000 - message bo ...

have tried this... If DCount("[lab no]", "data", "[lab no]=" & me.lab no & ) > 0_
Then
and get "Compile error: Expected: list separator or )"

Collapse -

Access 2000 - message boxes

by john_wills In reply to Access 2000 - message bo ...

Because you left the ampersand in: think of the meaning of what you are writing. That is not always easy in a new language, of course. The compiler expects something it can handle as a string after every "&", but you had a superfluous and therefore damaging "&". The third parameter of DCount is a string with the same format as the post-WHERE clause of an SQL SELECT statement. The parameter is composed of several parts, strung together by "&". The "&" unites separate items into a string. When the value being compared is a text, the text must be surrounded by apostrophes, so to put the second apostrophe in one needs an ampersand and a quotation of the second ampersand. When the value being compared is a number no apostrohe should be presentbefore or after, and hence no quotation and no linking ampersand after.

Collapse -

Access 2000 - message boxes

by sej In reply to Access 2000 - message bo ...

Thanks very much

Collapse -

Access 2000 - message boxes

by sej In reply to Access 2000 - message bo ...

This question was closed by the author

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums