MsgBox Functions (1 Viewer)

MSUKevin

Registered User.
Local time
Today, 19:50
Joined
May 16, 2001
Messages
75
Another question for this fine morning!,

I wanted to use a MsgBox with the Vbyesno buttons. DOes anyone know the way to code these buttons so you can have then either

(1) - Open a form with the Yes command
(2) - Close the msgbox with the No command and resume function

If someone could help I would appreciate it!

Thanks alot!
Kevin

(p.s. Sorry about all of the exclamation points... I've had too much coffee this morning already)
 

HJAMES

Registered User.
Local time
Today, 19:50
Joined
Jul 12, 2001
Messages
36
Try this....

Dim res As String

res = MsgBox("this is a test", vbYesNo)
Select Case res
Case vbYes
DoCmd.OpenForm "Form1"
Case vbNo
Exit Sub
End Select
 

MSUKevin

Registered User.
Local time
Today, 19:50
Joined
May 16, 2001
Messages
75
HJAMES,

Thanks for the help, that worked like a charm.

I have another question regarding msgboxes that you might be able to help me with:

The message box you just helped me create asks the user at the start of database if they would like to update the current US Canadian exchange rate. However, some of my users will not ever need to do this as they do not get Canadian customers, (or not often enough to have to upate exchange rates every day). I want to build in a chechbox on the message box that says something like:

"Click here to disable this message box"

and this would, like it says, disble the message box so it wouldn't be bothersome to those who don't need it.

I have seen this done before, but I don't know the coding involved... any suggestions?

Thanks in advance,
Kevin
 

HJAMES

Registered User.
Local time
Today, 19:50
Joined
Jul 12, 2001
Messages
36
Just condition the message code on the status of your check box. That should work.
 

MSUKevin

Registered User.
Local time
Today, 19:50
Joined
May 16, 2001
Messages
75
HJAMES,

"Just condition the message code on the status of your check box"...

I don't know the code for this and I also don't know how to get a check box on the message box. I'm fairly new with VB coding so if you know how to do this, or where I could find an example of this code for reference, I would appreciate it.

I tried to consult the Northwind.db in Access samples to copy what they use in their startup form (it has a checkbox to disable the form) but I wasn't able to find how to do this in a message textbox.

Your help on this matter is fully appreciated!

Thanks in advance...
Kevin
 

Fornatian

Dim Person
Local time
Today, 19:50
Joined
Sep 1, 2000
Messages
1,396
have you got user level security installed.

IF YES,
1. Build a small table with all your users in and a second field called 'showCanadian'.

On the startup form, find the record related to the Current User and if so, then show the messagebox, otherwise do ignore, somthing like:

Dim blnShowCanadian As Boolean
If DLookup("[showCanadian]", "MyUsersTable", "[TheUserField] = '" & CurrentUser & "'") = True Then
'give option to update
End If

Something along those lines should work.

IF NO,
For each persons, front end(assuming you have a split db), add a small table called 'showCanadian' with two field, one 'ID' integer field(PK) and another'ShowCanadian'.

Now base a form on that table and pull the field onto the form and the user will automatically be able to choose whether or not to update the Canadian rate. Build it into some kind of 'Options' screen and you can then reference the value, as above using a Dlookup statement.

Ian
 

HJAMES

Registered User.
Local time
Today, 19:50
Joined
Jul 12, 2001
Messages
36
I assume you have some kind of an opening screen. Put checkbox on your screen using the wizard.

In the same place you are have your message box code just add the first 3 lines(as shown below). Worked for me.


Dim res As String

If Check Then
Exit Sub
Else
res = MsgBox("Do You want to update Form1?", vbYesNo)
Select Case res
Case vbYes
DoCmd.OpenForm "Form2"
Case vbNo
Exit Sub
End Select
End If

If the box is checked is will bypass the message code.
 

MSUKevin

Registered User.
Local time
Today, 19:50
Joined
May 16, 2001
Messages
75
HJAMES,

We are almost there!!!

I have the code for the message box located in the 'On Load' event procedure on my switchboard form. The message box code runs when the form is loaded for the first time. I have placed the checkbox control on the bottom of the switchboard form and labeled it "Disable_CurrUpdate". The following is the code that I am using to run this command:

Dim res As String

If Me![Disable_CurrUpdate] = -1 Then
Exit Sub
Else
res = MsbBox ("Do you want to update Currency Exchange Rate?", vbYesNo)
Select Case res
Case vbYes
Docmd.OpenForm "Curr_exchange"
Case vbNo
Exit Sub
End Select
End If
End Sub

The problem that I am having now is that I cannot 'tick' the control on the switchboard form and I cannot figure out why!?!?! The checkbox "Disable_CurrUpdate" is not bound to a table or rowsource but I have built chkboxes before this way to preform tasks and have never had a problem...

I you have any idea what might be wrong I would appreciate the help... and the help that any of the other good people on this board have to offer!
Many thanks in advance..

Kevin
 

Users who are viewing this thread

Top Bottom