ClearlyAnIdiot
Registered User.
- Local time
- Tomorrow, 06:37
- Joined
- Aug 22, 2013
- Messages
- 39
Please note that I am a complete beginner in MS Access, and this may be impossible. I made a form(based on what I'll refer to as "Table 1") with a set of command buttons, and a some of them are meant to update existing records in another table (table 2), as well as table 1. The code is as follows:
Private Sub ExistingShareholder_Click()
Dim CompanyNo As Field
Dim ShareName As String
ShareName = InputBox _
(Prompt:="What is the shareholder's name?")
Dim Subroutine4 As String
Subroutine4 = "UPDATE table2 " & _
"Set ShareholderOf = 'CompanyNo' " & _
"WHERE Name = 'Sharename' "
DoCmd.RunSQL Subroutine4
End Sub
Basically, I want the Subroutine4 to recognise Sharename as the data I input to the inputbox, as well as the fact that CompanyNo is a field. If I put in some sample gibberish, such as
Subroutine4 = "UPDATE table2 " & _
"Set ShareholderOf = '1111' " & _
"WHERE Name = 'Person' "
it clearly recognises a field in table 2 that I'd named "person", and updates the "person" to be a shareholder of "1111". What I'm trying to ask is, how can I get the SQL to recognise what I've defined in the VBA?
Private Sub ExistingShareholder_Click()
Dim CompanyNo As Field
Dim ShareName As String
ShareName = InputBox _
(Prompt:="What is the shareholder's name?")
Dim Subroutine4 As String
Subroutine4 = "UPDATE table2 " & _
"Set ShareholderOf = 'CompanyNo' " & _
"WHERE Name = 'Sharename' "
DoCmd.RunSQL Subroutine4
End Sub
Basically, I want the Subroutine4 to recognise Sharename as the data I input to the inputbox, as well as the fact that CompanyNo is a field. If I put in some sample gibberish, such as
Subroutine4 = "UPDATE table2 " & _
"Set ShareholderOf = '1111' " & _
"WHERE Name = 'Person' "
it clearly recognises a field in table 2 that I'd named "person", and updates the "person" to be a shareholder of "1111". What I'm trying to ask is, how can I get the SQL to recognise what I've defined in the VBA?