Full Version: Msgbox Condition Statement
UtterAccess Forums > Microsoft® Access > Access Forms
djleister
I have a form with the contract number and a subform for all of the record detail. I would like when the form opens a message is displayed stating "Would you like to duplicate this record" if yes then the record will automatically duplicate and the form will open to display the new record; however if no is selected then the original record opens and displays on the form.
can figure out how to have the message display for Yes/No but the condition and action is what I am struggling with.
vtd
>>I can figure out how to have the message display for Yes/No but the condition and action is what I am struggling with. <<
CODE
Dim intResponse As Integer
strMsg = "Duplicate Record?"
intResponse = MsgBox(strMsg, vbYesNo + vbDefaultButton1, "Answer Me")
If intResponse = vbYes Then
  ' Duplicate record here
Else
  ' Show current Record here
End If

>>I would like when the form opens a message is displayed stating "Would you like to duplicate this record"<<
Beware that if you use the Form_Open or Form_Load (and possibly even in the Form_Current) Event, the Current Record data may not be visible on screen so the user doesn't know what he/she is copying.
djleister
I cannot seem to get the results I need. Let me start with this is the code I had for a button on my subform: (as you can see I need a couple of actions to happen prior to duplicating the record and then to SetFocus after the paste append.
Private Sub Command45_Click()
On Error GoTo Err_Command45_Click
Me.Parent![Status] = "CLOSED"
Me.Link = [HistoryID]
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
Me.Parent![Status] = "OPEN"
Me.ChgType.SetFocus
Exit_Command45_Click:
Exit Sub
Err_Command45_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command45_Click

End Sub
vtd
1. How does the posted code relate to the original question about the result of the MsgBox? Should this be a new Topic since the question does not sound anything like the original question? In fact, it doesn't use the MsgBox at all???
. Please describe what the code is supposed to do... Your code use DoMenuItem with acMenuVer70 which refers to Access 95 Menu and I don't remember Access 95 Menu items/commands. The DoMenuItem statements are probably created by some code wizards in Access but this makes it harder to debug/modify.
3. I am not sure the DoMenuItems applies to the data on the MainForm or the SubForm (and I do not know whether you want to copy record from the MainForm or both). Have you checked this out?
It's has been years since I used DoMenuItem. IIRC, Access 97 already had the warning that DoMenuItem may not be supported in future versions of Access and the code should be coverted to use RunCommand Method. Unfortunately, Microsoft never seem to get around to update some of the Wizards that create VBA code.
djleister
Mike,
No it is all related, because currently have a button which performs the duplicate record command (and yes I just used the wizard on Access 2003), but I want to remove this button so that the user doesn't accidentally start changing the record before duplicating it first; otherwise I lose historical data which I need to preserve in the database.
o my thought was to have a message box appear when the user selects the record of choice asking if they wish to duplicate.
Do you know of a better way to go about this, if so I am certainly all ears?
Oh and yes I need to copy records from both mainform and subform.
vtd
Mike???
id I missed something?
1. Are you saying that you always want to duplicate the record before editing (either the original record or newly duplicated record)?
2. Are you trying to do some sort of custom audit trail?
djleister
The user has two options:
. Normal editing of the original document but not changing the type.
2. Duplicating the record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was < record in order to preserve the original state of the document (government agency requirements) and then the new linked document's type can be changed along with any of the other fields.
Sorry with the Mike, I was <
vtd
Personally, I would set up as follows:
. Open the Form in "View-Only" mode. This can be done by setting the AllowEdits of the Form to No/False in the Design of the Form if suitable. If this is not suitable, e.g. you have unbound "navigation" Control (which required AloowEdits = True), then you need to set the Locked Property (and if required, the Enabled Property) of all the bound Controls.
2. Have 2 CommandButtons on the Form: "Edit Current Record" and "Copy and Edit the Copy" (or whatever names suitable for your set-up). If the user clicks/activates "Edit Current Record", reverse whatever you use in point 1 to enable the edit of the current record. If the user clicks/activates "Copy and Edit the Copy" then copy the Current Record, navigate to the newly-copied record and then reverse whatever you use in point 1 to enable the newly copied record (which is now the CurrentRecord on the Form).
IMHO, this is much clearer for the user to choose which action he/she should select. In addition, this would avoid the problem of picking the correct Event to present the Message Box I mentioned earlier.
Do note that I don't know your database and what I suggest above may not follow the "theme" of your database...
djleister
Okay I just got back into town today so I am going to attempt this..................................cross your fingers! I will let you know if I am successful or if I need further assistance.
Thank you so much................Deborah
djleister
It worked great!! Thank you so much for your suggestion and assistance.
vtd
You're welcome... Glad to help...
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.