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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a warning box to an existing combo box field

Status
Not open for further replies.

domino3

MIS
May 20, 2003
307
GB
I currently have a form which selects names from one combo box, then uses a second combo box (combo96)to select which event that person has been to. This works fine.

However, what I have now been asked to do is to add a message/warning box to show on screen if a particular field on the form has already been filled in for the that record.

I'm trying, therefore, to add more lines to the code in combo96 so that after it is updated with the selected event, it will look in the date_field, and bring up a warning message if the date field is not null.

The existing combo box is as follows:-

Private Sub Combo96_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[attending_id] = " & Me![Combo96]
Me.Bookmark = Me.RecordsetClone.Bookmark

End Sub

I can't work out what I need to add to the code above to then get the system to check the field called "date_field" and then bring a warning box if it is already full.

Any help would be much appreciated. Thank you.
 
If the date field is of date type, you can check if it is null. Where you check depend on whether it is the current record or record found by the combo that you want to check. Let us say it is the latter; something like this should suit:

Code:
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[attending_id] = " & Me![Combo96]
Me.Bookmark = Me.RecordsetClone.Bookmark
If Not IsNull(Me.Date_Field) Then
   MsgBox "Warning!"
End If



 
Thank you for your help.

However, is there any way of changing the font colour or size, or the position of the msgbox itself, to make the warning really obvious?
 
You can build a custom message box, which can be opened with the WindowMode set to acDialog, or you can add built in options:

[tt]MsgBox ("Warning", vbOKOnly + vbCritical)[/tt]

It is possible to format message boxes, but not a lot. You will find some posts on the topic.
 
What I've ended up doing is creating a form with a text box in big red letters which opens instead of the message box, as this seemed a simple enough solution for me to cope with.

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top