Check Boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two check boxes with option values as follows: pending = 1 and closed
= 2. I also have an unbound combo box. Is it possible to do the following: If
pending is checked then it shows a row source from a table with criteria and
if closed is checked then it shows a row source from the same table with
different criteria. How would you?
 
I have two check boxes with option values as follows: pending = 1 and closed
= 2. I also have an unbound combo box. Is it possible to do the following: If
pending is checked then it shows a row source from a table with criteria and
if closed is checked then it shows a row source from the same table with
different criteria. How would you?

A check box can only have a value of -1 or 0.

If you have check boxes with values of 1 and 2, then you do not have
check boxes, you have an Option Group, using check boxes for
selection. The Option Group will get it's value from whichever box has
been selected.

Leave the combo box rowsource blank.

Code the Option Group AfterUpdate event:

If Me!OptionGroupName = 1 Then
ComboName.Rowsource = "Select TableName.FieldName from TableName Where
[SomeField] = " & SomeCriteria
Else
ComboName.Rowsource = "Select TableName.FieldName from TableName Where
[SomeField] = " & SomeOtherCriteria

End If

The above assumes that [SomeField] is a number datatype.
If it is a Text datatype, use:
Where [SomeField] ='" & SomeCriteria & "';"

In VBA help, look up
Where Clause + Restrict data to a subset of records
for how to properly write the criteria.
 
I'm still having problems option group my check box is blank. The following
is my code. Please help!!! Thank you!!!

Private Sub PendingandClosed_AfterUpdate()

If Me!PendingandClosed = 1 Then
cboCustomerNames.RowSource = "SELECT tblCustomerInfo.[Customer Name],
tblTransactionInformation.[Status of Deal] FROM tblTransactionInformation
INNER JOIN tblCustomerInfo ON tblTransactionInformation.[Customer Name] =
tblCustomerInfo.[Customer Name] WHERE (((tblTransactionInformation.[Status of
Deal])= &Pending)) ORDER BY tblCustomerInfo.[Customer Name]"

Else

cboCustomerNames.RowSource = "SELECT tblCustomerInfo.[Customer Name],
tblTransactionInformation.[Status of Deal] FROM tblTransactionInformation
INNER JOIN tblCustomerInfo ON tblTransactionInformation.[Customer Name] =
tblCustomerInfo.[Customer Name] WHERE (((tblTransactionInformation.[Status of
Deal])= &closed)) OR (((tblTransactionInformation.[Status of Deal])=&dead))"



End If
End Sub


fredg said:
I have two check boxes with option values as follows: pending = 1 and closed
= 2. I also have an unbound combo box. Is it possible to do the following: If
pending is checked then it shows a row source from a table with criteria and
if closed is checked then it shows a row source from the same table with
different criteria. How would you?

A check box can only have a value of -1 or 0.

If you have check boxes with values of 1 and 2, then you do not have
check boxes, you have an Option Group, using check boxes for
selection. The Option Group will get it's value from whichever box has
been selected.

Leave the combo box rowsource blank.

Code the Option Group AfterUpdate event:

If Me!OptionGroupName = 1 Then
ComboName.Rowsource = "Select TableName.FieldName from TableName Where
[SomeField] = " & SomeCriteria
Else
ComboName.Rowsource = "Select TableName.FieldName from TableName Where
[SomeField] = " & SomeOtherCriteria

End If

The above assumes that [SomeField] is a number datatype.
If it is a Text datatype, use:
Where [SomeField] ='" & SomeCriteria & "';"

In VBA help, look up
Where Clause + Restrict data to a subset of records
for how to properly write the criteria.
 
Back
Top