Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System Messages

Status
Not open for further replies.

Gazer44

Technical User
Mar 4, 2002
211
US
Is it possible to change the wording of a system mssg.

i.e. If duplicate record entered in a Primary key field can the mssg be setup simply as 'duplicate record entered' INSTEAD of the long system mssg which isn't that clear.

Any help appreciated. Cheers
 
It is possible to turn off System Messages, even if it's only temporary, and create your own message.

I.e.

In the event that causes the system message to occur, use this code.

DoCmd.SetWarnings = False
If MsgBox("Duplicate record entered.", 65, "Warning") = vbOk Then
'Do whatever you want in here
Else
'Do something else in here
End if
Docmd.setwarnings = True

HTH

Pete
 
thanks,

does this code go into the 'after update' of the Primary key field ?

AND

what exactly do you mean by the 'Do whatever you want in here' & 'Do something else in here' lines

cheers
 
Yes it would go in the AfterUpdate event of the primary key control but you would have to perform a check first to see whether the user was entering a duplicate record.

If they were then you could use the above code.

The Do whatever you want/do something else means what to do depending on what button the user presses.

The 65 in the MsgBox line of code tells Access what kind of Msgbox to display.

The VbOKCancel msgbox = 1
A VbInformation msgbox = 64

so add these together and you get an Ok/Cancel message box styled as an information box. Check out Access help for all the values or you can just type VbOkCancel+VbInformation instead of 65.

If the user pressed cancel you could stop the primary control losing focus so they could change what they entered, you'd do this by entering some code in the Else part of the above code where it says 'Do something else

If they pressed Ok you could just do nothing and let them carry on, so don't put any code in the part that says 'Do whatever you want.

Here's a better example:

DoCmd.SetWarnings = False
If MsgBox("Duplicate record entered.", 65, "Warning") = vbCancel Then
[YourControl].SetFocus
End if

If you enter that into the AfterUpdate event and then have

Docmd.setwarnings = True

on the On Got Focus event of your control, you should be away.

HTH,

Pete
 
Sorry, the

on the On Got Focus event of your control, you should be away.

line should read:

on the On Lost Focus event of your control, you should be away.

Cheers,

Pete
 
Thanks for the help, I'll see how i get on & let u know.

cheers
 
Pete,

you mention 'performing a check first to see whether the user was entering a duplicate record'.

How, what's the code for that.

cheers
 
Have tried this but the mssg appears whether a duplicate record entered or not.

Any other ideas?

cheers

 
Sorry I've taken ages to respond, I forgot that I was involved in this thread and didn't see it again until you posted. Sorry!

Anyway, check out this thread thread181-278020 for information on how to check for duplicate values by code.

Cheers,

Pete
 
Thanks for the reply Pete. This prob is on access 2000.

I'm Having probs with the 'dlookup' function. I've put this in:-

If DLookup("[SocSecID]", "[Client]", "[SocSecID] =" & Me!SocSecID) Then
MsgBox "duplicate, try again"
DoCmd.GoToControl "SocSecID"
End If

Table name- Client
Field on Table name- SocSecID
Form field name- SocSecID

I get a 'run time error 3464. Data mismatch in criteria'

The SocSecID field is a text field with input mask of 000-00-000.

any ideas??
 
Try not encasing the table name, ie Client, in square brackets. Also I may be wrong but DLookup returns a Null or a field value so you'll have to check that it's not null to be sure that there is a duplicate record. So try the code this way:

If Not (DLookup("[SocSecID]", "Client", "[SocSecID] = " & Me!SocSecID) = vbNull) Then
MsgBox "duplicate, try again"
DoCmd.GoToControl "SocSecID"
End If

Hope that helps,

Cheers,

Pete
 
Cheers, I've managed to sort this out using:-

If DLookup("[SocSecID]", "[Client]", "[SocSecID] =" & Me!SocSecID) Then
MsgBox "duplicate, try again"
DoCmd.GoToControl "SocSecID"
End If

The problem was the 'data type'on the 'SocsecID' field. It was set to 'text'. Changed it to 'number' and it worked!!

Thanks for you help.
Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top