ClearlyAnIdiot
Registered User.
- Local time
- Today, 12:34
- Joined
- Aug 22, 2013
- Messages
- 39
I apologise in advanced, as there will be some VBA in this, but I figured it would fit better in the query section.
I ran a very similar code with near-identical SQL, with only the fields and tables changed, and it had worked before. However, after changing the fields and tables, I repeatedly get error 3134 for "syntax". The code was
You can ignore the userform and inputbox if they're not important in this, but I figured they might just be.
When I run "Strsub" and "strsubb" by themselves, they both come up with errors, so it's not one or the other.
There are two tables in this. A table of companies, which has its form open, and a child table of companies and their people.
I wanted strsubb to put in a record where a person is added, their name based on the inputbox, and their associated company to be marked as the one that is in the field "companyno".
Strsub is meant to set the same person's roles to be whatever was clicked on the userform. If it's important, the roles are in a lookup wizard with multiple choices.
I ran a very similar code with near-identical SQL, with only the fields and tables changed, and it had worked before. However, after changing the fields and tables, I repeatedly get error 3134 for "syntax". The code was
Code:
Private Sub UpdateI_Click()
Dim PerName As String, strsubb As String, Popup As Role, Strsub As String
PerName = InputBox("What is their name?")
strsubb = "INSERT INTO Company-personID (CompanyNo, Name) VALUES ('" & Me.CompanyNo & "', '" & PerName & "');"
DoCmd.RunSQL strsubb
Set Popup = New Role
Popup.Show
Select Case Popup.Tag
Case 1
Strsub = "UPDATE Company-personID SET [RolesPerformed] = 'Director' WHERE [Name] = '" & PerName & "'"
Case 2
Strsub = "UPDATE Company-personID SET [RolesPerformed] = 'AlternateDirector' WHERE [Name] = '" & PerName & "'"
Case 3
Strsub = "UPDATE Company-personID SET [RolesPerformed] = 'ReserveDirector' WHERE [Name] = '" & PerName & "'"
Case 4
Strsub = "UPDATE Company-personID SET [RolesPerformed] = 'Shareholder' WHERE [Name] = '" & PerName & "'"
End Select
DoCmd.RunSQL Strsub
Set Popup = Nothing
End Sub
When I run "Strsub" and "strsubb" by themselves, they both come up with errors, so it's not one or the other.
There are two tables in this. A table of companies, which has its form open, and a child table of companies and their people.
I wanted strsubb to put in a record where a person is added, their name based on the inputbox, and their associated company to be marked as the one that is in the field "companyno".
Strsub is meant to set the same person's roles to be whatever was clicked on the userform. If it's important, the roles are in a lookup wizard with multiple choices.