F
Fysh
I created a table with 4 primary composite key. I created a form with a
combo box and several listboxes to update this table. This all works fine.
The table is like
tblName
ID autonumber
ActID PK
QualID PK
PracID PK
CatID PK
Required Yes/No
Enabled Yes/No
Now I created another form (form1) with a subform (form2) unbound just to
try to figure this out. On form1 I created 3 combo boxes and private
function and is called after all the combo boxes are not null. This function
updates the form2 with the correct amount of check boxes and labels
corresponding to the check boxes. Also, the check boxes are checked if
required and tells you whether it is enabled or not. Once again this works
fine. The problem I am having is I only want to show the ones that relate to
the 3 combo boxes. I tried using a query and as my recordset using this
query gives me an error stating too few paramters expexted 3. Here is my
function can someone point out what I am doing wrong? I commented out what I
thought I needed to do, but it didn't work. I have been coding for awhile,
but sometimes you get stuck and don't see what you might be doing wrong.
Private Function UpdateForm2()
Dim dbs As Database
Dim rst As Recordset
Dim strSelect As Recordset
Dim varX As Integer
Dim varC As Variant
Set dbs = CurrentDb
' Set strSelect = "SELECT * " & " FROM tblActQualPracCat " & " WHERE
(tblActQualPracCat.PracID= " & Me.cboPracticalName
' & " AND tblActQualPracCat.ActID = " & Me.cboActivityName & " And
tblActQualPracCat.QualID = " & Me.cboTypeOfQualification & ");"
Set rst = dbs.OpenRecordset("tblActQualPracCat")
If rst.RecordCount > 1 Then
varX = rst.RecordCount
Do
For k = 1 To varX
varC = DLookup("Category", "tblCategory", "CATID= " &
rst![CATID])
Forms!Form1.Form2.Form("chk" & k).Visible = True
Forms!Form1.Form2.Form("lbl" & k).Caption = varC
If rst![Required] = True Then
Forms!Form1.Form2.Form("chk" & k) = True
Else
Forms!Form1.Form2.Form("chk" & k) = False
End If
If rst![Enabled] = True Then
Forms!Form1.Form2.Form("chk" & k).Enabled = True
Else
Forms!Form1.Form2.Form("chk" & k).Enabled = False
End If
rst.MoveNext
Next k
Loop Until varX
End If
Forms!Form1.Form2.Form.Requery
End Function
Anyway thanks for any input.
combo box and several listboxes to update this table. This all works fine.
The table is like
tblName
ID autonumber
ActID PK
QualID PK
PracID PK
CatID PK
Required Yes/No
Enabled Yes/No
Now I created another form (form1) with a subform (form2) unbound just to
try to figure this out. On form1 I created 3 combo boxes and private
function and is called after all the combo boxes are not null. This function
updates the form2 with the correct amount of check boxes and labels
corresponding to the check boxes. Also, the check boxes are checked if
required and tells you whether it is enabled or not. Once again this works
fine. The problem I am having is I only want to show the ones that relate to
the 3 combo boxes. I tried using a query and as my recordset using this
query gives me an error stating too few paramters expexted 3. Here is my
function can someone point out what I am doing wrong? I commented out what I
thought I needed to do, but it didn't work. I have been coding for awhile,
but sometimes you get stuck and don't see what you might be doing wrong.
Private Function UpdateForm2()
Dim dbs As Database
Dim rst As Recordset
Dim strSelect As Recordset
Dim varX As Integer
Dim varC As Variant
Set dbs = CurrentDb
' Set strSelect = "SELECT * " & " FROM tblActQualPracCat " & " WHERE
(tblActQualPracCat.PracID= " & Me.cboPracticalName
' & " AND tblActQualPracCat.ActID = " & Me.cboActivityName & " And
tblActQualPracCat.QualID = " & Me.cboTypeOfQualification & ");"
Set rst = dbs.OpenRecordset("tblActQualPracCat")
If rst.RecordCount > 1 Then
varX = rst.RecordCount
Do
For k = 1 To varX
varC = DLookup("Category", "tblCategory", "CATID= " &
rst![CATID])
Forms!Form1.Form2.Form("chk" & k).Visible = True
Forms!Form1.Form2.Form("lbl" & k).Caption = varC
If rst![Required] = True Then
Forms!Form1.Form2.Form("chk" & k) = True
Else
Forms!Form1.Form2.Form("chk" & k) = False
End If
If rst![Enabled] = True Then
Forms!Form1.Form2.Form("chk" & k).Enabled = True
Else
Forms!Form1.Form2.Form("chk" & k).Enabled = False
End If
rst.MoveNext
Next k
Loop Until varX
End If
Forms!Form1.Form2.Form.Requery
End Function
Anyway thanks for any input.