I am using an unbound form in MS Access to: 1) select an "event venue" via combo box, 2) select pre-registered participants to the event via cascading combo box, thus filling in form data such as last name, first name, etc from "Paticipants" table relative to each venue.
This all works...next I add data to four new fields based upon participant desired activities.
I need to now "read" all of the form data and send it to table "B" or "c" dependent upon the combo box selected "Venue". Tables "B" and "c" have corresponding fields equal to the form. Using the below code. The IF statement works fine, but when the command button is clicked, the "set rec=db.OpenRecordset("select * from " & strMytable & "") line returns a "From clause error." I have tried all that I can think of....any help? Thanks in advance. Just trying to get this one database done. First time using Access. Thanks
Private Sub Command129_Click()
Dim db As Database
Dim rec As Recordset
Dim strMytable As String
Set db = CurrentDb
If Me.Combo77.Value = "Cherry Creek 2019" Then
strMytable = "CC tourny results"
ElseIf Me.Combo77.Value = "Pueblo 2019" Then
strMytable = "pueblo tourny results"
End If
sec rec=db.OpenRecordset("select * from " & strMytable & "")
rec.AddNew
rec("Last Name") = Me.LastName.text
rec.Update
rec.Close
db.Close
End Sub