Ambigious Name Detected: Reset

aabrazil1

New Member
Joined
Feb 11, 2024
Messages
19
Office Version
  1. 2021
Platform
  1. Windows
Hello All,

Both forms below are assigned to the same worksheet. The ambiguous name is "reset" because they both have a delete and reset button. Should I rename part of the 'reset code' for the second form? Which part? Below is the code from each.


1707768753088.png


Form 1 Code:

VBA Code:
Private Sub cmdDelete_Click()
       If Selected_List = 0 Then
       MsgBox "No row is selected.", vbOKOnly + vbInformation, "Delete"
       Exit Sub
       End If
       Dim i As VbMsgBoxResult
       i = MsgBox("Do you want to delete the selected record?", vbYesNo + vbQuestion, "Confirmation")
      If i = vbNo Then Exit Sub
      ThisWorkbook.Sheets("Database").Rows(Selected_List + 1).Delete
      Call Reset                                                                                                      'THE ERROR MESSEGE IS HERE : AMBIGUOUS NAME DETECTED
      MsgBox "Selected record has been deleted.", vbOKOnly + vbInformation, "Deleted"
 End Sub

Private Sub cmdEdit_Click()
     If Selected_List = 0 Then
      MsgBox "No row is selected.", vbOKOnly + vbInformation, "Edit"
      Exit Sub
      End If
      'Code to update the value to respective controls
      Dim sPR As String
     Me.txtRowNumber.Value = Selected_List + 1
    Me.txtnumber.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 1)
    Me.Txttitle.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 2)
    Me.lbsystem.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 3)
    sPR = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 4)
     If sPR = "Y" Then
        Me.optyes.Value = True
     Else
        Me.optno.Value = True
     End If
    Me.lbdefectcode.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 5)
    Me.lbexpected.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 6) 
    Me.lbactual.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 7)
    Me.txtproblem.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 8)
    Me.txtnotes.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 9)
    MsgBox "Please make the required changes and click on 'Save' button to update.", vbOKOnly + vbInformation, "Edit"
End Sub

Private Sub cmdReset_Click()
   Dim msgValue As VbMsgBoxResult
    msgValue = MsgBox("Do you want to rerest the form?", vbYesNo + vbInformation, "Confirmation")
    If msgValue = vbNo Then Exit Sub
   Call Reset                       '
End Sub

Private Sub cmdSave_Click()
     Dim msgValue As VbMsgBoxResult 
     msgValue = MsgBox("Please check you entries and confirm you want to save the data", vbYesNo + vbInformation, "Confirmation")
   If msgValue = vbNo Then Exit Sub
    Call Submit    
    Call Reset
End Sub


1707768787533.png


Form 2 code:

VBA Code:
Private Sub cmdReset_Click()
    Dim msgValue As VbMsgBoxResult
    msgValue = MsgBox("Do you want to rerest the form?", vbYesNo + vbInformation, "Confirmation")
     If msgValue = vbNo Then Exit Sub
    Call Reset
End Sub

Private Sub cmdSave_Click()
   Dim msgValue As VbMsgBoxResult
   msgValue = MsgBox("Please check you entries and confirm you want to save the data", vbYesNo + vbInformation, "Confirmation")
   If msgValue = vbNo Then Exit Sub
    Call Submit
    Call Reset
End Sub

Thank you,
Tony
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Where is/are the Reset sub(s)
 
Upvote 0
Where is/are the Reset sub(s)

Hello Rory, I made them larger font and bold below. Thank you

Form 1
VBA Code:
Private Sub cmdDelete_Click()
       If Selected_List = 0 Then
       MsgBox "No row is selected.", vbOKOnly + vbInformation, "Delete"
       Exit Sub
       End If
       Dim i As VbMsgBoxResult
       i = MsgBox("Do you want to delete the selected record?", vbYesNo + vbQuestion, "Confirmation")
      If i = vbNo Then Exit Sub
      ThisWorkbook.Sheets("Database").Rows(Selected_List + 1).Delete
      Call Reset                                      [B] 'THE ERROR MESSEGE IS HERE : AMBIGUOUS NAME DETECTED[/B]
      MsgBox "Selected record has been deleted.", vbOKOnly + vbInformation, "Deleted"
 End Sub

Private Sub cmdEdit_Click()
     If Selected_List = 0 Then
      MsgBox "No row is selected.", vbOKOnly + vbInformation, "Edit"
      Exit Sub
      End If
      'Code to update the value to respective controls
      Dim sPR As String
     Me.txtRowNumber.Value = Selected_List + 1
    Me.txtnumber.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 1)
    Me.Txttitle.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 2)
    Me.lbsystem.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 3)
    sPR = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 4)
     If sPR = "Y" Then
        Me.optyes.Value = True
     Else
        Me.optno.Value = True
     End If
    Me.lbdefectcode.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 5)
    Me.lbexpected.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 6) 
    Me.lbactual.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 7)
    Me.txtproblem.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 8)
    Me.txtnotes.Value = Me.lbdatabase.List(Me.lbdatabase.ListIndex, 9)
    MsgBox "Please make the required changes and click on 'Save' button to update.", vbOKOnly + vbInformation, "Edit"
End Sub

[SIZE=5][B]Private Sub cmdReset_Click()[/B]
   Dim msgValue As VbMsgBoxResult
    msgValue = MsgBox("Do you want to rerest the form?", vbYesNo + vbInformation, "Confirmation")
    If msgValue = vbNo Then Exit Sub
   Call Reset                       '
End Sub[/SIZE]

Private Sub cmdSave_Click()
     Dim msgValue As VbMsgBoxResult 
     msgValue = MsgBox("Please check you entries and confirm you want to save the data", vbYesNo + vbInformation, "Confirmation")
   If msgValue = vbNo Then Exit Sub
    Call Submit    
    Call Reset                     [B]THE ERROR MESSAGE IS ALSO HERE[/B]
End Sub

Form 2

VBA Code:
[SIZE=5][B]Private Sub cmdReset_Click()[/B]
    Dim msgValue As VbMsgBoxResult
    msgValue = MsgBox("Do you want to reset the form?", vbYesNo + vbInformation, "Confirmation")
     If msgValue = vbNo Then Exit Sub
    Call Reset
End Sub[/SIZE]

Private Sub cmdSave_Click()
   Dim msgValue As VbMsgBoxResult
   msgValue = MsgBox("Please check you entries and confirm you want to save the data", vbYesNo + vbInformation, "Confirmation")
   If msgValue = vbNo Then Exit Sub
    Call Submit
    Call Reset
End Sub
 
Upvote 0
No, those are click events for buttons. I'm talking about the Reset sub that you call from all four of them.
 
Upvote 0
No, those are click events for buttons. I'm talking about the Reset sub that you call from all four of them.
Hello Rory. It's solved. Thank you. The reset sub is in module 2 and I renamed reset2 to map to form 2. The code works now. Thank you very much
 
Upvote 0
It sounds like those codes probably belong in each form.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,435
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top