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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update checkbox in table instead of form

Status
Not open for further replies.

Lightlancer

Programmer
Jul 18, 2008
88
NL
Hey all,

I have a table named: tblStatus

in that table there is only 1 record with 8 fields

in the form there are 2 buttons for each field, named:
IN
or
OUT

when i click IN, the checkbox for this field must go "True"
When i click OUT, the checkbox for this field must go "False"

how can this be done?

Greetz

Lightlancer
 
hi,

Am I missing something or would this not work:

Place the four fields on the form and make them invisible, let's assume they're called field1, field2, etc

Code:
sub btn1On_OnClick()
field1=true
end sub

sub btn1Off_OnClick()
field1=false
end sub

sub btn2On_OnClick()
field2=true
end sub

sub btn2Off_OnClick()
field1=false
end sub

etc...

To cut down on code a bit you could create 4 option groups and add 2 radio buttons to each captioned On and Off. Set the value of one to -1 and the other to 0:

Code:
sub Option1_AfterUpdate()
field1=me!Option1
end sub

sub option2_AfterUpdate()
field2=me!Option2
end sub

etc

Good luck, JB
 

How about binding toggle buttons to the fields and change the caption depending on it's state using the after update event? Don't forget to set the record source for the form to the table firsly.


Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 
Between football games. So,
Lightlancer - what if that field is neither In nor Out? Maybe at that moment of time, that field is not in play. Have you heard of the Triple State of checkboxes? You'll find it on the property sheet of the checkbox. Checkboxes usually have only values of 0 (unchecked) or -1 (checked) corresponding to Yes/No or True/False or On/Off.
A triplestate checkbox can have the three values of True/Yes/On (-1), False/No/Off (0) and grayed out (Null state). Or Yes(-1), No(0) or Null.
You can then use a Select Case statement to test for each state. Such as:
Private Sub SomeButton_Click()
Select Case Me!chkActivity
Case Is = -1
' Filter for 'Active' returns -1
DoCmd.OpenQuery "qryFind_Active_Inactive"

Case Is = 0
' Filter for 'Inactive' returns 0
DoCmd.OpenQuery "qryFind_Active_Inactive"

Case Else
' Null so all values need to be returned
DoCmd.OpenQuery "qryFind_Active_Inactive"
End Select
End Sub

Just thought I'd toss that out. Maybe come in useful one day.
 
How are ya Lightlancer . . .

Instead of two buttons per, you only need one each! Simply [blue]toggle[/blue] the [blue]button caption[/blue] to indicate what the user is setting. Example of the [blue]On Click[blue] event of a button:
Code:
[blue]   If Me![[purple][B][I]ButtonName[/I][/B][/purple]].Caption = "Set In" Then
      Me![[purple][B][I]CheckboxName[/I][/B][/purple]] = True
      Me![[purple][B][I]ButtonName[/I][/B][/purple]].Caption = "Set Out"
   Else
      Me![[purple][B][I]CheckboxName[/I][/B][/purple]] = False
      Me![[purple][B][I]ButtonName[/I][/B][/purple]].Caption = "Set In"
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
well i got it working with 2 buttons, In and Out,
when button is clicked, this code will be run:

Code:
Me![CheckboxName] = True

or false offcourse,

well when i click the button, the checkbox goes True,
when i close the form and reopen it, the checkbox is False again,
it should be True,
its like the record in the table is blocked or something but it isnt.

am i doing something wrong???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top