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

FIELDS IN MSGBOX 1

Status
Not open for further replies.

desikan

Technical User
Feb 2, 2001
105
AE
I am having a msg box in after update event with following code :

MsgBox "Units transferred " & Me!qty & Me!order & Me!item, vbOKOnly + vbInformation

This message works fine but ideally I want the message like this :
MsgBox Me!qty "nos of" & Me!item "transferred to" & Me!location, vbOKOnly + vbInformation

I am not getting the syntax right. Grateful for any help




 
you could assign those values to variables and then add them to the message box so for instance:

Dim Item As String

Item = Me!item

Msg = MsgBox(Item, vbOkOnly, "Msg")

Hope thats a bit of help!

Rob
 
Hi!

You are missing a couple of concationation marks (&):

[tt]MsgBox Me!qty & " nos of " & Me!item & " transferred to " & Me!location, vbOKOnly + vbInformation[/tt]

They must be present between any variable/forms reference and a text. I've also added couple of xtra spaces.

HTH Roy-Vidar
 
Thanks Roy and modica82 for the replies.

I corrected my statement as per syntax provided by Roy and it worked beautifully. Thanks a lot.

The method provided by modica82 is interesting and I will try it later.

 
Hi, as per by my previous message, I tried the code in a single form and it worked ok.

Now I have another situation with a form and a sub form (continous). A record is selected using check box in the sub form and a command button starts a yes/no msgbox with "yes" starting append/delete query and "no" starting a single form.

Now how do I identify the correct record (in the field defintion of msgbox) in the sub form where the action is going to be done?

Thanks in advance for all the trouble that you are taking.


 
Hi again!

I'm not 100 per cent sure what you're asking.

The reference Me!SomeControl will always refer to the current record on the current, the record where the cursoer is at present or where the "selected" mark is in the record selector. When pressing a button, Me!SomeControl will refer to that the value residing in that control for the current record.

Now, if the user have selected a record for some sort of action with a check box, and have the possibility to "click somewhere else" before clicking the command button, this might give some confusion (perhaps the user has clicked the next record?).

One, perhaps easy way of doing this, is to move your code from the command button to the after update event of the checkbox (also providing a Cancel option) to minimize such risk. The reference would still be Me!somecontrol & " sometekst " ....

Else, one would perhaps think of using the forms recordset clone, looping thru it with a do loop, and choosing the record where the check box is checked.

See if some of the above might apply to your challenge, and don't hesitate to report back.

HTH Roy-Vidar
 
Hi,Roy
I am using a command button on my Main form to run the vbyesno command which further starts either macro37 or macro39 as mentioned in the syntax given below.

Now as you rightly mentioned it is better to have this code in after update of check box itself and hence I tried it and it works ok except for 2 problems;

1. I am unable to set up the vbyesnocancel syntax so that cancel will bring back the user to the existing form.I tried to set it up as -- Else cancel=True but without success

2. Also vbyesno starts whether check box is made no to yes (which should be one required) or when clicked from yes to no also (which is to be prevented).


Private Sub BOX_AfterUpdate()
Dim sMsgReturn
sMsgReturn = MsgBox("CLICK YES IF YOU WANT TO SHIFT THE SELECTED CARD AS SPARE AND CLICK NO IF YOU WANT TO TRANSFER TO ANOTHER NODE-Take care as your actions cannot be reversed ", vbYesNoCancel, "Select option yes or no or cancel")

If sMsgReturn = vbYes Then
MsgBox Me![QTY-WKG] & " NOS OF SPARE CARD -- " & Me![CARD NAME] & " TRANSFERRED TO " & Me![CARD NAME], vbOKOnly + vbInformation
DoCmd.RunMacro "macro37"
If sMsgReturn = vbNo Then
DoCmd.RunMacro "macro39"
Else
DoCmd.RunMacro "macro3"
End If
End Sub

Thanks for your help.
 
Hi,
I just changed the last part of the code as below:
ElseIf sMsgReturn = vbNo Then
DoCmd.RunMacro "macro39"
Else
Cancel=True
End If
End Sub

Now the code runs ok.
The problem which remains is when a person clicks cancel he returns to the form and the checkbox remains ticked and if he wants to untick the box, the code runs again unnecessarily and I would like to prevent this action.

Grateful for any ideas.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top