message box with message based on tbl

  • Thread starter Thread starter Brook
  • Start date Start date
B

Brook

I would like to create a custom message box when opening a
form that would pull the message based on a column
(specialnotices) from tblSpecialNotices. Is this possible?

thanks,

Brook
 
Brook said:
I would like to create a custom message box when opening a
form that would pull the message based on a column
(specialnotices) from tblSpecialNotices. Is this possible?


Probably.

Take a look at the DLookup function to retrieve the notice
from the table. You can use the MsgBox function to display
the message.

MsgBox DLookup("specialnotices", "tblSpecialNotices")
 
Thank you very much for the Reply!

One other question, is there a way that I can have this
set up so that the message box only comes up if there is
data in the SpecialNotices Field in my table?

Brook
 
Brook said:
Thank you very much for the Reply!

One other question, is there a way that I can have this
set up so that the message box only comes up if there is
data in the SpecialNotices Field in my table?


Not sure under what circumstances you want to do this, but,
if you want to do it when the form first opens, put the code
in the form's Load event.

Dim varNotice As Variant
. . .
varNotice = DLookup("specialnotices", "tblSpecialNotices")
If Nz(varNotice, "") <> "" Then
MsgBox varNotice
End If
 
Again,

Thanks for the help,

This works great, except for one thing. In my
tblSpecialNotices I have three Columns CompanyID, Company
Name, and SpecialNotice. I have frmCallCenter, and a
button that takes me to frmCallDetails for that record
based on the CompanyID. I am wanting to put this custom
message box on my frmCallDetails when it opens from the
frmCallCenter, but I want the message box to compare the
CompanyID from frmCallDetails to tblSpecialNotices based
on the CompanyID, and display a Message box with the
information for that CompanyID in the Message Box.

Do you think this is something that will be possible
with this Custom Message Box?

Let me know if this is unclear.

Brook
 
Just to let you know that I was able to figure that last
part of my question out. What I did was set up a query and
have the query perform a field comparison between the
tblCallCenter (what my frmDetails is based on) and the
tblSpecial Notices, which gave me the message box that I
was looking for.

Thanks for all your help!

Brook
 
Brook said:
Just to let you know that I was able to figure that last
part of my question out. What I did was set up a query and
have the query perform a field comparison between the
tblCallCenter (what my frmDetails is based on) and the
tblSpecial Notices, which gave me the message box that I
was looking for.

A separate query is unecessary, the DLookup funtion is
actually a way to run a simple query. The third argument
can be used to specify the criteria:

varNotice = DLookup("specialnotices", _
"tblSpecialNotices", _
"CompanyID = "& Forms!frmCallCenter.CompanyID)
--
Marsh
MVP [MS Access]



 
thanks for the info about not needing the additional
query. Do you know of a way to force the size of the
Message Box therefore wrapping the text with the Message
Box?

Thanks,

Brook
-----Original Message-----
Brook said:
Just to let you know that I was able to figure that last
part of my question out. What I did was set up a query and
have the query perform a field comparison between the
tblCallCenter (what my frmDetails is based on) and the
tblSpecial Notices, which gave me the message box that I
was looking for.

A separate query is unecessary, the DLookup funtion is
actually a way to run a simple query. The third argument
can be used to specify the criteria:

varNotice = DLookup("specialnotices", _
"tblSpecialNotices", _
"CompanyID = "& Forms! frmCallCenter.CompanyID)
--
Marsh
MVP [MS Access]




.
 
Brook said:
thanks for the info about not needing the additional
query. Do you know of a way to force the size of the
Message Box therefore wrapping the text with the Message
Box?

The message box function does not provide an option for
that.

If it's important enough, you have two ways to go with this.
One is to create your own form and procedure to use instead
of MsgBox.

The other is to insert the carriage return - line feed
characters at strategic locations in the notices so that it
breaks where you want it to. This is easy to do when you
are entering or editing the notices data by holding down the
Ctrl key and hitting the Enter key. If your users are not
complete idiots, this gives them a great degree of control
over how the message will appear on the screen when you
display it in a MsgBox.
--
Marsh
MVP [MS Access]


 
Back
Top