Option Groups

G

Guest

I'm still having problems with my option group the 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.
Was this post helpful to you?
 
G

Guest

Penny,

Looking at your code, I cannot tell as to whether or not you verified
whether the information that Fred gave you worked or not. Regardless, is
PendingandClosed the name of the option group frame or one of the checkboxes
inside the group?

If it is not the name of the frame, place the code in there. Those values
of 1 and 2 that you selected are for the group itself.

Also, if you step into the code, is it hitting any of the lines in the code?
Is it getting to the If statement and stepping into it or into the Else
section?

Let us know what the results are and what is occuring (errors, etc.).

Lance





Penny said:
I'm still having problems with my option group the 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.
Was this post helpful to you?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top