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

Microsoft Access - Form 1

Status
Not open for further replies.

PJname

MIS
Jun 15, 2004
73
US
Can someone provide me the Visual Basic coding for a Microsoft Access form for a field where if it is = TRUE , a pop-up message box will appear?

I have a "Delete" field on my form and if a check is placed in this box, I want a message to pop-up similar to the following: "***If this activity is to be deleted and the "Late Date" is before the next outage, make sure you submit an AR for this work order to have Dates changed in the WMS system and record the AR # on this form.****"
 
Private Sub chkTrueFalse_AfterUpdate()
If Me.chkTrueFalse = False Then
MsgBox "***If this activity is to be deleted and the 'Late Date' is before the next outage, make sure you submit an AR for this work order to have Dates changed in the WMS system and record the AR # on this form.****"
End If
End Sub

"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
Thanks NorthNone for your response.

I assume this coding would be placed in the "On Click" section on the properties list?
 
I placed it on the AfterUpdate event
"Private Sub chkTrueFalse_AfterUpdate()"


"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
NorthNone,


I did insert in the "After Update" section after looking at the code. I am not a regular VB user.

Thanks again.....
 
You are welcome. Glad I could help :)

"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
Hi NorthNone,

I have another question concerning MS Access form.

VB coding checking the following:

If fielda and fieldb IS Blank or Null, display a message stating that you must check either ADD or Delete Box.....
 
Use "Nz()" to trap for null values and convert them to blank strings. Then test for both fields having blank strings.

Dim txtA As String
Dim txtB As String
txtA = Nz(Me.fielda, "")
txtB = Nz(Me.fieldb, "")
If txtA = "" And txtB = "" Then
MsgBox "You must check either ADD or Delete Box....."
End If


"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
NorthNone

where would the above code be inserted in the properties listing for the form?
 
Depends on when you need to stop them. Before form update? On Click to leave the record? Depends on the setup of your form. Take a look at the possible events. Break them down to what is happening to trigger an event, and I find the one where you want that criteria to be evalutated.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
misscrf did a good job of outlining the possibilities for you. Let me know if you need any further assistance.
NorthNone

"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
OK, this is what I would like the message to appear.

There is a third field called Requestor.

i would like for the message to display if the user selects the Requestor drop down box listing employees where if the ADD or DELETE button is null, for it to pop up the message.

I inserted the code on the Requestor field, in the On click
Field names: Add ckhTrueFalse (Deletes)


Private Sub Requestor_Click()
Dim txtA As String
Dim txtB As String
txtA = Nz(Me.[Add], "")
txtB = Nz([Me.[chkTrueFalse], "")
If txtA = "" And txtB = "" Then
MsgBox "You must check either the ADD or DELETE Box above....."
End If
End Sub

but something is amiss, because I do not have the code correct because it does not work if I leave the two fields blank and click on the requestor drop down box, it continues without giving me the message.
 
Try the AfterUpdate event of the requestor drop down box.

"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
You will also need to test for no value in the requestor box which I named Combo19:
txtA = Nz(Me.fielda, "")
txtB = Nz(Me.fieldb, "")
If txtA = "" And txtB = "" And Combo19 <> "" Then
MsgBox "You must check either ADD or Delete Box....."
End If
Otherwise you will get a message when you change from having a value there and removing that value.

"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
Does it make a difference that the Add and Delete is a Yes/No format?
 
That will affect how you write your code. This assumed that your checkboxes are not set for triple state.

Dim chkA As Long
Dim chkB As Long

chkA = Me.fielda
chkB = Me.fieldb

If chkA = 0 And chkB = 0 And Combo19 <> "" Then
MsgBox "You must check either ADD or Delete Box....."
End If

"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
BTW I put the above code in the BeforeUpdate event instead of the AfterUpdate event and it worked just fine.

"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
Glad I could help out. :)

"Character cannot be developed in ease and quiet. Only through experience of trial and suffering can the soul be strengthened, ambition inspired, and success achieved." - Helen Keller
 
Hi, NorthNone!

Sorry to intrude here, but I'm desperate for the answer to a question you asked a couple of years ago, thread702-289543, and I wonder whether you ever found out what to do about it.

Could you let me know if you had any luck in this thread thread702-1376458

TIA very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top