check box in my form

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

Guest

My form base on tblClientInfo table, one client has more then one address. I
need to some how control my check box, one client can have only one box
checked.
For example;
RecID ClientID Address CheckBox
--01-----1-----123 5str.--True
--02-----1-----123 2str.--False
--03-----1-----123 4str.--False

If I check in my form the check box for RecID # 2, then RecID # 1 should be
unchecked.
Please help me !!!!!
Thank you
 
Why don't you just use an option group instead of checkboxes? They're
automatically set up to only allow one to be chosen at a time.

hth
-Jayyde
 
I didn't think about that.
Thank you


Jayyde said:
Why don't you just use an option group instead of checkboxes? They're
automatically set up to only allow one to be chosen at a time.

hth
-Jayyde
 
Sorry, But option group is not working for me. Is it any other soluting.


My form base on tblClientInfo table, one client has more then one address.
I
need to some how control my check box, one client can have only one box
checked.
For example;
RecID ClientID Address CheckBox
--01-----1-----123 5str.--True
--02-----1-----123 2str.--False
--03-----1-----123 4str.--False

If I check in my form the check box for RecID # 2, then RecID # 1 should be
unchecked.
Please help me !!!!!
Thank you
 
What's your code?

GGill said:
Sorry, But option group is not working for me. Is it any other soluting.


My form base on tblClientInfo table, one client has more then one
address.
I
need to some how control my check box, one client can have only one box
checked.
For example;
RecID ClientID Address CheckBox
--01-----1-----123 5str.--True
--02-----1-----123 2str.--False
--03-----1-----123 4str.--False

If I check in my form the check box for RecID # 2, then RecID # 1 should
be
unchecked.
Please help me !!!!!
Thank you
 
I have form , the record source for that form is "tblClientInfo". it will
view data as Tabular. For example when i select from combo box 'Client' = 1
then it will view 3 records for that client, so from here if i checked record
02 then that record should be true and record 01 should be False. Basically
for one client the check box = true only for one of those records.
 
My form base on tblClientInfo table, one client has more then one address. I
need to some how control my check box, one client can have only one box
checked.
For example;
RecID ClientID Address CheckBox
--01-----1-----123 5str.--True
--02-----1-----123 2str.--False
--03-----1-----123 4str.--False

If I check in my form the check box for RecID # 2, then RecID # 1 should be
unchecked.
Please help me !!!!!
Thank you

There's no easy way to do this in the table design. Where are the
addresses stored? Surely you have a joined address table in a subform,
no?

Assuming that you do, you'll need some VBA code in the checkbox's
AfterUpdate event. Something like:

Private Sub chkMyCheckbox_AfterUpdate()
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.Querydef
On Error GoTo Proc_Error
strSQL = "UPDATE [Addresses] SET CheckBox = " & Not Me!chkMyCheckbox _
& " WHERE ClientID = " & Me!ClientID & " AND RecID <> " & Me!RecID
Set db = CurrentDb
Set qd = db.CreateQuerydef("", strSQL)
qd.Execute dbFailOnError
Set qd = Nothing
Proc_Exit: Exit Sub
Proc_Error:
Msgbox "Error " & Err.Number & " in chkMyCheckbox_AfterUpdate:" & _
vbCrLf & Err.Description
On Error Resume Next
Set qd = Nothing
Resume Proc_Exit
End Sub


John W. Vinson[MVP]
 
Thank you so much, i will try that.


John Vinson said:
My form base on tblClientInfo table, one client has more then one address. I
need to some how control my check box, one client can have only one box
checked.
For example;
RecID ClientID Address CheckBox
--01-----1-----123 5str.--True
--02-----1-----123 2str.--False
--03-----1-----123 4str.--False

If I check in my form the check box for RecID # 2, then RecID # 1 should be
unchecked.
Please help me !!!!!
Thank you

There's no easy way to do this in the table design. Where are the
addresses stored? Surely you have a joined address table in a subform,
no?

Assuming that you do, you'll need some VBA code in the checkbox's
AfterUpdate event. Something like:

Private Sub chkMyCheckbox_AfterUpdate()
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.Querydef
On Error GoTo Proc_Error
strSQL = "UPDATE [Addresses] SET CheckBox = " & Not Me!chkMyCheckbox _
& " WHERE ClientID = " & Me!ClientID & " AND RecID <> " & Me!RecID
Set db = CurrentDb
Set qd = db.CreateQuerydef("", strSQL)
qd.Execute dbFailOnError
Set qd = Nothing
Proc_Exit: Exit Sub
Proc_Error:
Msgbox "Error " & Err.Number & " in chkMyCheckbox_AfterUpdate:" & _
vbCrLf & Err.Description
On Error Resume Next
Set qd = Nothing
Resume Proc_Exit
End Sub


John W. Vinson[MVP]
 
I used your code and it's not working .

GGill said:
Thank you so much, i will try that.


John Vinson said:
My form base on tblClientInfo table, one client has more then one address. I
need to some how control my check box, one client can have only one box
checked.
For example;
RecID ClientID Address CheckBox
--01-----1-----123 5str.--True
--02-----1-----123 2str.--False
--03-----1-----123 4str.--False

If I check in my form the check box for RecID # 2, then RecID # 1 should be
unchecked.
Please help me !!!!!
Thank you

There's no easy way to do this in the table design. Where are the
addresses stored? Surely you have a joined address table in a subform,
no?

Assuming that you do, you'll need some VBA code in the checkbox's
AfterUpdate event. Something like:

Private Sub chkMyCheckbox_AfterUpdate()
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.Querydef
On Error GoTo Proc_Error
strSQL = "UPDATE [Addresses] SET CheckBox = " & Not Me!chkMyCheckbox _
& " WHERE ClientID = " & Me!ClientID & " AND RecID <> " & Me!RecID
Set db = CurrentDb
Set qd = db.CreateQuerydef("", strSQL)
qd.Execute dbFailOnError
Set qd = Nothing
Proc_Exit: Exit Sub
Proc_Error:
Msgbox "Error " & Err.Number & " in chkMyCheckbox_AfterUpdate:" & _
vbCrLf & Err.Description
On Error Resume Next
Set qd = Nothing
Resume Proc_Exit
End Sub


John W. Vinson[MVP]
 
I just changed data type in my table and your code it did work.
Thank you so much.

GGill said:
I used your code and it's not working .

GGill said:
Thank you so much, i will try that.


John Vinson said:
On Fri, 3 Mar 2006 10:40:30 -0800, GGill

My form base on tblClientInfo table, one client has more then one address. I
need to some how control my check box, one client can have only one box
checked.
For example;
RecID ClientID Address CheckBox
--01-----1-----123 5str.--True
--02-----1-----123 2str.--False
--03-----1-----123 4str.--False

If I check in my form the check box for RecID # 2, then RecID # 1 should be
unchecked.
Please help me !!!!!
Thank you

There's no easy way to do this in the table design. Where are the
addresses stored? Surely you have a joined address table in a subform,
no?

Assuming that you do, you'll need some VBA code in the checkbox's
AfterUpdate event. Something like:

Private Sub chkMyCheckbox_AfterUpdate()
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.Querydef
On Error GoTo Proc_Error
strSQL = "UPDATE [Addresses] SET CheckBox = " & Not Me!chkMyCheckbox _
& " WHERE ClientID = " & Me!ClientID & " AND RecID <> " & Me!RecID
Set db = CurrentDb
Set qd = db.CreateQuerydef("", strSQL)
qd.Execute dbFailOnError
Set qd = Nothing
Proc_Exit: Exit Sub
Proc_Error:
Msgbox "Error " & Err.Number & " in chkMyCheckbox_AfterUpdate:" & _
vbCrLf & Err.Description
On Error Resume Next
Set qd = Nothing
Resume Proc_Exit
End Sub


John W. Vinson[MVP]
 

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

Back
Top