Source of Argument not Optional error?

Skrej

Board Regular
Joined
May 31, 2013
Messages
149
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a button on a user form, than when clicked is giving me an Argument not Optional Error, and I can't see what I'm missing.

Here's the code from the userform,

Code:
Private Sub cmdUpdate_Click()
UpdateTextBoxes
End Sub

And, here's the subroutine I'm trying to call.

Code:
Sub UpdateTextBoxes(Record_Number As Long)
  Dim Row As Long
   Row = Record_Number
     With ThisWorkbook.Sheets("Data")
       .Cells(Row, "A").Value = ESLtester.tboUpdateName.Value
       .Cells(Row, "B").Value = ESLtester.tboUpdateID.Value
       .Cells(Row, "C").Value = Cells(Row, "C").Offset(0, 2)
       .Cells(Row, "D").Value = Cells(Row, "D").Offset(0, 3)
       .Cells(Row, "E").Value = ESLtester.tboUpdateTest.Value
       .Cells(Row, "F").Value = ESLtester.tboUpdateScore.Value
       .Cells(Row, "G").Value = ESLtester.tboUpdateDate.Value
   End With
      ShowCurrentRecord
End Sub

Tried going through and commenting out each line, but I still get the error even after commenting everything out. Have tried changing some variable names, no difference.

I have essentially the same subroutine for another button that just references different text boxes on the user form, and it works fine.

Any suggestions as to what I'm overlooking?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
When you call the UpdateTextBoxes procedure, you need to include this argument: Record_Number As Long

For example, to update row 3, you would say:

Code:
UpdateTextBoxes Record_Number:=3

' or simply

UpdateTextBoxes 3
 
Last edited:
Upvote 0
Solution
Hi,

I have a button on a user form, than when clicked is giving me an Argument not Optional Error, and I can't see what I'm missing.

Here's the code from the userform,

Code:
Private Sub cmdUpdate_Click()
[B][COLOR=#008000]UpdateTextBoxes[/COLOR][/B]
End Sub

And, here's the subroutine I'm trying to call.

Code:
Sub UpdateTextBoxes([B][COLOR=#FF0000]Record_Number As Long[/COLOR][/B])
  Dim Row As Long
   Row = Record_Number
     With ThisWorkbook.Sheets("Data")
       .Cells(Row, "A").Value = ESLtester.tboUpdateName.Value
       .Cells(Row, "B").Value = ESLtester.tboUpdateID.Value
       .Cells(Row, "C").Value = Cells(Row, "C").Offset(0, 2)
       .Cells(Row, "D").Value = Cells(Row, "D").Offset(0, 3)
       .Cells(Row, "E").Value = ESLtester.tboUpdateTest.Value
       .Cells(Row, "F").Value = ESLtester.tboUpdateScore.Value
       .Cells(Row, "G").Value = ESLtester.tboUpdateDate.Value
   End With
      ShowCurrentRecord
End Sub

Tried going through and commenting out each line, but I still get the error even after commenting everything out. Have tried changing some variable names, no difference.

I have essentially the same subroutine for another button that just references different text boxes on the user form, and it works fine.

Any suggestions as to what I'm overlooking?
The UpdateTextoxes subroutine requires an argument when called (see the red highlighted text)... but when you call it (the green highlighted text), you did not provide that required argument.
 
Upvote 0
Thank you both, Iliace and Rick. I appreciate the help.

I now realize why I didn't have this error the last time I used that sub, is that I had the button call a sub, which then called the update sub, so I wasn't getting the error b/c I wasn't missing the argument.

Guess I just forgot to do it this time, getting tired.

Time for some wine and mindless TV instead of coding, methinks....

Thanks again.
 
Last edited:
Upvote 0
Time for some wine and mindless TV instead of coding, methinks....
Personally, I prefer some wine and mindless coding :cool:

Good luck with the rest of your project.
 
Upvote 0

Forum statistics

Threads
1,203,728
Messages
6,057,012
Members
444,902
Latest member
ExerciseInFutility

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