A family of Microsoft relational database management systems designed for ease of use.
Tom -
Was my reply deleted for a specific reason?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I create a form.
I add a
I add a button.
I right click on button and select Properties
I click on the dropdown next to On Click and select [Event Procedure]
Click on the three dots and a Sub is created with the name of the button
I add code to the sub
Save the form
Open the form
Click on the button
Get an error message:
How do I fix this?
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Tom -
Was my reply deleted for a specific reason?
Your code works fine for me. Copy it to a new database. Not the same problem, right?
So there is something about the current db that you haven't told us. Does the code compile? Do you have missing references?
Have you tried performing an Office Repair?
Private Sub Command0_Click()
Dim nLocation As Integer
Dim i As Integer
Dim strNameOfItem As String
Dim strValueOfItem As String
Dim vVariant(200, 3) As Variant
i = 1
Do Until Environ(i) = ""
vVariant(i, 3) = Environ(i)
nLocation = i
strNameOfItem = Left(vVariant(i, 3), InStr(1, vVariant(i, 3), "=", vbTextCompare) - 1)
strValueOfItem = Right(vVariant(i, 3), Len(vVariant(i, 3)) - InStr(1, vVariant(i, 3), "="))
Debug.Print strNameOfItem
Debug.Print strValueOfItem
Debug.Print i, vVariant(i, 3)
i = i + 1
Loop
End Sub
Unfortunately, there's not enough information in your post to attempt a suggestion.
Show us (Copy and paste, not screenshot, please) what is in that sub. That's where the information needed should be.