Adding a pop up warning

  • Thread starter Thread starter tom b
  • Start date Start date
T

tom b

I WANT TO FLASH A MESSAGE THAT SAYS "PART NOT ON FILE" TO
POP UP WHEN YOU TYPE A PART NUMBER THEN TAB OR ENTER TO
THE NEXT FIELD. WE HAVE THOUSANDS OF PARTS IN STOCK BUT
WE CANNOT JUST GO THRU PARTS EN-MASS TO CREATE THE PART
NUMBER AND DESCRIPTION FIELD. IT IS EASIER TO DO THIS
WHEN AN ORDER COMES IN. USUALLY 35-50 A DAY MAX WITH 1-3
LINES EACH. NOT ALL PARTS WILL HAVE DESRIPTIONS AND SOME
PARTS ARE ONE TIME DEALS AND WON'T BE STOCKED (SPECIAL
ORDERS..)

I HAVE A COMMAND BUTTON ON THE FORM THAT OPENS A FORM
THAT ALLOWS YOU TO ENTER THAT PART NUMBER AND MEMO
DESCRIPTION OF THAT PART. YOU CAN THEN CLOSE THAT FORM
AND GO ABOUT YOUR WORK.

THE POPUP IS IMPORTANT BECAUSE THE ONLY ERROR YOU MIGHT
GET IS AFTER ALL THE ORDER IS ENTERED, THEN YOU MUST BACK
TRACK AND REFRESH. I THINK IF IT POPS UP WHEN YOU TRY TO
LEAVE THE FIELD, YOU CAN IMMEDIATELY ENTER THE PART INFO
ON THE OTHER FORM, THEN RETURN TO PROCESS THE ORDER.
AGAIN SINCE NOT ALL PARTS WILL HAVE A DESCRIPTION, THAT
IS NO INDICIA.

I AM NO ACCESS GENIUS, SO YOU MIGHT NEED TO TELL ME
EXACTLY WHERE TO ENTER WHAT. I'VE READ SOME MESSAGES ON
YOU SITE AND SOME ANSWERS LIKE "ENTER THIS STRING" MEAN
NOTHING TO ME. (ENTER THE STRING WHERE..., DOES SOMETHING
ELSE HAVE TO BE DONE.

THANKS IN ADVANCE...
 
Well Tom!

First of all, using capital letters is the same thing as shouting, so please
use small letters (not correct word in english I know).

About you popup message. You could use someting like this in your texbox
BeforeUpdate_Event:

If WhatEverNeedsToBeChecked Then
MsgBox "PART NOT ON FILE"
End If

Or if you allways want to display this messege just skip the If...Then...End
If

I read through your post and couldn´t find some validation for your MsgBox
to be displayed. Which is the reason why I can´t help you out which more
than this. I´m sure though that you DON´t want to display this message every
singel time the user try to leav the control on the form. So if you need
help with the validation please give us some more information of when you
want the message to pop up.

// Niklas
 
Sorry about the capitolization.

basicly it only needs to pop up when you enter a part
number that is not recorded in the part number table. It
seems that Access only gives messages like "duplicate
record" or "The Microsoft Jet Database engine cannot find
a record in the table 'parts table' with key matching
field(s) 'part number'" when you want to leave the
current record (i.e. go to next record or exit the
current form). Access waits untill you populate the
entire record and then gives the error message and not
the offending field.

thanks again
 
Well a combobox have a propertie called "NotInList which can be used. If you
want a simple solution you could allways put the code (MsgBox
"YourTextGoesHere") and that´s it!

But quit often when ther´´s not the a data in the underlying recordsource
for the list/combobox the user want´s the option to add it in an easy way so
you could use this:

Following code goes in the combobox NotInList_Event
=================================================
Private Sub txtNameOnYourComboBox_NotInList(NewData As String, Response As
Integer)
Dim result
Dim Msg As String
Dim CR As String

CR = Chr$(13)

' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub

' Ask the user if he or she wishes to add the new data.
Msg = "'" & NewData & "' is not in list." & CR & CR
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
' If the user chose Yes, start the data form in data entry
' mode as a dialog form, passing the new data in
' NewData to the OpenForm method's OpenArgs argument. The
' OpenArgs argument is used in data form's Form_Load event
' procedure.
DoCmd.OpenForm "frmYourFormNameWhichYouAddPartnumber", , , , acAdd,
acDialog, NewData
End If

' Look for the partnumber the user created in the data form.
result = DLookup("[UniqueFieldInTableForPartNo]",
"tblYourTableNameForPartNumbers", _
"[YourFieldThatContainsTheNameOrDescriptionOfThePartNo]='" &
NewData & "'")

' (UniqueFieldInTableForPartNois often a autonumber field (in the table so
in your case 'it should be the partnumber it self which needs to be indexed
as well to speed up the 'serching for correct partnumber.)

If IsNull(result) Then
' If the partnumber was not created, set the Response argument
' to suppress an error message and undo changes.
Response = acDataErrContinue
' Display a customized message.
MsgBox "It din´t succeded. Try again!"
Else
' If the partnumber was created, set the Response argument to
' indicate that new data is being added.
Response = acDataErrAdded
End If
End Sub
==========================================

And the following code goes in the partnumber form´s load_event (the form
used to add new partnumbers into your table).
============================================
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
' If form's OpenArgs property has a value, assign the contents
' of OpenArgs to the CompanyName field. OpenArgs will contain
' a company name if this form is opened using the OpenForm
' method with an OpenArgs argument, as done in the Orders
' form's PartNumber_NotInList event procedure.

Me![txtNameOnControlInFormDisplayingNameOrDescriptionOnPartNumberItem] =
Me.OpenArgs
End If
End Sub

========================================

That´s it!

// Niklas

"tom b" <[email protected]> skrev i meddelandet
Sorry about the capitolization.

basicly it only needs to pop up when you enter a part
number that is not recorded in the part number table. It
seems that Access only gives messages like "duplicate
record" or "The Microsoft Jet Database engine cannot find
a record in the table 'parts table' with key matching
field(s) 'part number'" when you want to leave the
current record (i.e. go to next record or exit the
current form). Access waits untill you populate the
entire record and then gives the error message and not
the offending field.

thanks again
 
Back
Top