This is doign my head in now.
I have 28 combo boxes on a form, which I want to insert data into the table as they are chaged. Each one will pass the same sets of data just with different parameters which come from the form.
Rather than putting the same code to insert on each of the 28 combo boxes I thought it would be easier to create a function to do it and pass the parameters to it through a sub on the AfterUPdate event of the combo box.
I need to pass 4 parameters, if I only put 1 in there it works fine, but when I start putting more in it doesnt work and I get compile errors or syntax errors.
Could someone point me in the right direction.
Sub routine:
Function is Module 1:
Thanks
I have 28 combo boxes on a form, which I want to insert data into the table as they are chaged. Each one will pass the same sets of data just with different parameters which come from the form.
Rather than putting the same code to insert on each of the 28 combo boxes I thought it would be easier to create a function to do it and pass the parameters to it through a sub on the AfterUPdate event of the combo box.
I need to pass 4 parameters, if I only put 1 in there it works fine, but when I start putting more in it doesnt work and I get compile errors or syntax errors.
Could someone point me in the right direction.
Sub routine:
Code:
Private Sub cboMonday1_AfterUpdate()
If Me.cboMonday1 = 1 Then
Me.cboMonday1.BackColor = vbGreen
Me.cboMonday1.ForeColor = vbBlack
Else
If Me.cboMonday1 = 2 Then
Me.cboMonday1.BackColor = vbRed
Me.cboMonday1.ForeColor = vbWhite
Else
If Me.cboMonday1 = 3 Then
Me.cboMonday1.BackColor = vbBlue
Me.cboMonday1.ForeColor = vbWhite
Else
Me.cboMonday1.BackColor = vbWhite
Me.cboMonday1.ForeColor = vbBlack
End If
End If
End If
If IsNull(Me.cboMonday1) Then
Else
Dim MemberID, AvailabilityID, TimeslotID As Integer
Dim AvailableDate As Date
MemberID = 37
AvailabilityID = Me.cboMonday1
MemberID = 37
TimeslotID = 1
AvailableDate = Me.txtMonday
insertavilability (MemberID, AvailabilityID, TimeslotID, AvailableDate)
End If
End Sub
Function is Module 1:
Code:
Public Function insertavilability(MemberID As Integer, AvailabilityID As Integer, TimeslotID As Integer, AvailableDate As Date)
DoCmd.RunSQL "INSERT INTO tblmemberavailability (MemberID, AvailableDate, AvailabilityID, TimeslotID) VALUES (" & MemberID & ",'" & AvailableDate & "'," & AvailabilityID & "," & TimeslotID & ")"
End Function
Thanks