Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

all values of combobox same as one combo box 1

Status
Not open for further replies.

NewTexican

Technical User
Dec 10, 2004
95
US
I previously got some helpful help with the following code, but I'm having some troubles now that I'm trying to add to it. A matrix of checkboxes and combo boxes in a form are populated when the form is opened. The check boxes are being populated correctly, I'm trying to use the same code to populate the combo boxes, but I'm getting a type mismatch error. The debug doesn't like the following line of code:
Me!Combo12.Value = (Not rstab.NoMatch) And rstab![Address Type]
that line works well for the checkbox, but not for the combo box. I guess I don't understand nomatch, only for boolean????


Public Sub updatecontrols()

Dim dbd As Database
Dim rstab As DAO.Recordset
Dim sqllst1, sqllst2, sqllst3, sqllst4, sqllst5, sqllst6 As String
Dim mail1, mail2, mail3, mail4, mail5, mail6 As Boolean
Dim compnum As Variant
Dim addtype As Variant
Dim compname As Variant

compnum = Forms![common company].[Company Numeric]

compname = Forms![common company].[Company Name]

Me!Label45.Caption = Nz(compname, "")

Set dbd = CurrentDb
Set rstab = dbd.OpenRecordset("Company-Mailout T", dbOpenDynaset)

sqllst1 = "[company numeric] = " & compnum & " and [company mailout num] = " & 1
sqllst2 = "[company numeric] = " & compnum & " and [company mailout num] = " & 2
sqllst3 = "[company numeric] = " & compnum & " and [company mailout num] = " & 3
sqllst4 = "[company numeric] = " & compnum & " and [company mailout num] = " & 4
sqllst5 = "[company numeric] = " & compnum & " and [company mailout num] = " & 5
sqllst6 = "[company numeric] = " & compnum & " and [company mailout num] = " & 6

rstab.FindFirst sqllst1
Me!Check11.Value = (Not rstab.NoMatch) And rstab![Send Mailout]
Me!Combo11.Value = (Not rstab.NoMatch) And rstab![Address Type]
rstab.FindFirst sqllst2
Me!Check12.Value = (Not rstab.NoMatch) And rstab![Send Mailout]
Me!Combo12.Value = (Not rstab.NoMatch) And rstab![Address Type]
rstab.FindFirst sqllst3
Me!Check13.Value = (Not rstab.NoMatch) And rstab![Send Mailout]
Me!Combo13.Value = (Not rstab.NoMatch) And rstab![Address Type]
rstab.FindFirst sqllst4
Me!Check14.Value = (Not rstab.NoMatch) And rstab![Send Mailout]
Me!Combo14.Value = (Not rstab.NoMatch) And rstab![Address Type]
rstab.FindFirst sqllst5
Me!Check15.Value = (Not rstab.NoMatch) And rstab![Send Mailout]
Me!Combo15.Value = (Not rstab.NoMatch) And rstab![Address Type]
rstab.FindFirst sqllst6
Me!Check16.Value = (Not rstab.NoMatch) And rstab![Send Mailout]
Me!Combo16.Value = (Not rstab.NoMatch) And rstab![Address Type]
rstab.Close

Set dbd = Nothing
Set rstab = Nothing
End Sub
 
Yes, I believe you're right, booleans only on True/False controls.
So, maybe this...

Me!Check11.Value = (Not rstab.NoMatch) And rstab![Send Mailout]
If Check11 Then Me!Combo11.Value = rstab![Address Type]

or

If Not rstab.NoMatch Then Me!Combo11.Value = rstab![Address Type]

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top