Popup Warning

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need help programming a form operation. When the form looses focus or is
saved (thru a button) I need it to make a check. It should perform the check
as follows:

If QTYREC is lower than QTYORD and WONBR contains “--“ then popup a form
that says “You need to reorder parts†or if QTYREC is lower than QTYAVAIL
then popup a form that says “You need to make a scrap report.â€

I am lousy with VBA and could use a little help. Can someone help code this?
All of the above should be one event. Any help is greatly appreciated.
 
Jackle,

Well, it's pretty much just like you said :-) ...

If Me.QTYREC < Me.QTYORD And WONBR Like "*--*" Then
MsgBox “You need to reorder parts.â€
ElseIf Me.QTYREC < Me.QTYAVAIL Then
MsgBox “You need to make a scrap report.â€
End If
 
I generally know what to say but i have a problem with foreign languages. HA.
it seems to hang on the MsgBox area. It involks the debuggerer. any advice?
 
Private Sub btnCompare_Click()

If Me.QTYREC < Me.QTYORD And WONBR Like "*--*" Then
MsgBox “You need to reorder parts.â€
ElseIf Me.QTYREC < Me.QTYAVAIL Then
MsgBox “You need to make a scrap report.â€
End If
 
Jackle,

Hmmm. That looks incredibly similar to the code I suggested! :-)

It would be best to put a Me in front of the WONBR, it was a typo in
what I gave you to not inclde that, but in fact it should still work.
So here's the next question... Are QTYREC, QTYORD, WONBR, and QTYAVAIL,
the correct names and spelling of the controls on your form? Or the
fields in the table that the form is based on?
 
yes, verbatim. when it involkes debuggerer, those msgbox lines are red. They
also snag the dubuggerer on the 'need', or 2nd word???? creapy? (or crappy?)
 
Jackle,

This is very strange, and I don't really understand, but I notice the
quote marks in the MsgBox lines are sloping, so maybe it is some sort of
weird transformation of them done by virtue of the format of your
original post, which I copy/pasted from. Try copy/pasting the below
into your code instead, with the plain text quote marks...

If Me.QTYREC < Me.QTYORD And Me.WONBR Like "*--*" Then
MsgBox "You need to reorder parts."
ElseIf Me.QTYREC < Me.QTYAVAIL Then
MsgBox "You need to make a scrap report."
End If
 
you are very perceptive! the angled quotes are actually (2) single quotes put
together! like you said, it must have been a paisty error. it is good now.
thanks.
 
I did a little changing of field names. can you help wrap the two seperate
statements in to the Private Sub btnSaveRecord_Click() button? If I "update"
once, it doesn't reexecute the comparison if i do it a second time. It might
be easier to tie it to the safe record button. this button is used to save
every record.

Private Sub Form_AfterUpdate()

If Me.[Quantity Recieved] < Me.[WO Start Qty] And Me.[Part Numb:] Like
"*--*" Then
MsgBox "You need to reorder parts", vbInformation, "REORDER PARTS"""
ElseIf Me.[Quantity Recieved] < Me.[Quantity:] Then
MsgBox "You need to make a scrap report", vbInformation, "SCRAP PARTS"""
End If


End Sub

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Private Sub btnSaveRecord_Click()
On Error GoTo Err_btnSaveRecord_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_btnSaveRecord_Click:
Exit Sub

Err_btnSaveRecord_Click:
MsgBox Err.DESCRIPTION
Resume Exit_btnSaveRecord_Click

End Sub
 
Back
Top