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

If is null Msg Box Help 2

Status
Not open for further replies.

ZmrAbdulla

Technical User
Apr 22, 2003
4,364
AE
Hi All,
The following code works fine if the user omit the date and try to save the record
'====================code============'
Private Sub Command50_Click()
On Error GoTo Err_Command50_Click

If IsNull(Date) Then
MsgBox "Please enter the date !!!", _
vbCritical + vbOKOnly, _
"Cartridge & Toner Inventory"

Cancel = True
Exit_Command50_Click:
Exit Sub

Err_Command50_Click:

Resume Exit_Command50_Click
End If
End Sub
'====================code============'
My question is What will be the code if the field (here it is Date) is on a subform? And the command button on the Main form.

Second question
One of my main forms have 3 fields
Name
TelNumber
FaxNumber

I need to use a MsgBox to tell the user If he omits any of the field and try to save.
If it is Name then tell "Plase enter the name"

Or If it is TelNumber then "Please enter the TelNumber"
Etc...etc..
But if the user omit two of them then the MsgBox should tell him the "Plase enter the Name and the TelNumber"

Is this possible?
Regards



Zameer Abdulla

 
The answer to your first question should be reasonably simple, you could just Reference the subform using the Forms collection.

So bascially,

If Isnull(Forms!FormName.DateTextbox.text) then blah

for the second question, try something like the following.

dim msgString as string

If isnull(name) = true then
msgString = "Please enter the Name"
end if
if isnull(TelNumber) = true then
if msgString = "" then
msgString = "Please enter the TelNumber"
else
msgString = msgString & "and the TelNumber"
end if
end if
if isnull(faxnumber) = true then
if msgString = "" then
msgString = "Please enter the FaxNumber"
else
msgString = msgString & "and the FaxNumber"
end if
end if

J
 
Hi,
Thank you for the quick response..
Still I am not able to bring the MsgBox on the first question
You wrote
If Isnull(Forms!FormName.DateTextbox.text) then .....

My command button is on the main form and the textbox is on the subform. unfortunately this bit of code is not working.
Can you please tell me what I am doing wrong?
I didn't test the second answer. I will test it and tell you the result

Regards

Zameer Abdulla

 
Zameer,

Code:
If IsNull(Me!subformControlName.Form!Date) Then

...where subformControlName is the name of the subform control on your main form (not necessarily the same as the name of the subform itself).

See this link for more info:


Ken S.

p.s. Is "Date" really the name of a field on your form? If so, I would consider changing it. In general it's not a good idea to give your form objects the same name as built-in Access functions, methods, or properties.
 
Hi,jimbone,

I had a similiar problem as the one faced by Abdulla and I tried your solution on before update function but I am getting error as "list separator ),

If you don't mind, would you please check the code again?

Many thanks
 
Hi, Abdulla,
I think I may have some more information about your problem.

If you don't mind, would you please send your exact requirement to desikan@emirates.net.ae

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top