updating checkbox field,,,,


A

accessdenied

I'm pretty new to access and hardly have worked with checkboxes before
soo .. here my problem..

I have a form that the user fills out.. theres a combo field on the
form with yes or no to a project. When the form is filled out.. to
figure out if the project is complete or not.. the project is set to
yes or no.

all projects that are marked yes is fine.. but all projects that are
marked no .. the user has to go back and fix.. once the project is
fixed the user has to go back and update the record marking the project
to YES then update. This part is fine..

I wanted to add a checkbox next to the field "project" yes/no ( that is
a combo field) ..

-I went into my table added a field called "fixed" with datatype
"yes/no"
-On my form I added a checkbox field and labeled that "fixed"

In my code I thought I could update as I did the others but i get an
error..

Compile Error:
Method or data member not found

This maybe an easy question but I stated before I new to access to any
help would be appreciated..

Thanks !!

Heres the code if you wanted to look.. again thanks


Code:
--------------------

Private Sub Command62_Click()
Dim f1 As String
Dim f14 As String
'***changed to variant data type
Dim f13 As Variant

ControlNo.SetFocus
f1 = ControlNo.Text & " "
f14 = Fixed.Text
DATECLOSE.SetFocus
'***test to insure DATECLOSE has a value

If Not IsNull(DATECLOSE) And IsDate(DATECLOSE) Then
f13 = DATECLOSE.Text
End If
'***create sql string based on whether f13 is a date or not
If IsDate(f13) Then
strSQL = "UPDATE tblInspections SET tblInspections.Fixed = '" & f14 & "', tblInspections.DATECLOSE = #" & f13 & "# WHERE tblInspections.ControlNo = '" & f1 & "'"
Else
strSQL = "UPDATE tblInspections SET tblInspections.Fixed = '" & f14 & "', tblInspections.dateclose = null WHERE tblInspections.ControlNo = '" & f1 & "'"
End If
CurrentDb.Execute strSQL

End Sub

--------------------
 
Ad

Advertisements

R

Reid

The problem is the following statement:

f14 = Fixed.Text

A Checkbox does not have a "Text" attribute. You should use the "Value"
member instead.

Note that a Checkbox contains a boolean/bit value, thus you should dim your
variable as Boolean when you reference it's value. Or you can simply use the
control's value in any boolean arguement, like this:

IF Me.Fixed = True THEN
MsgBox "Checkbox = True/Yes/-1"
ELSE
MsgBox "Checkbox = False/No/0"
END IF

accessdenied said:
I'm pretty new to access and hardly have worked with checkboxes before
soo .. here my problem..

I have a form that the user fills out.. theres a combo field on the
form with yes or no to a project. When the form is filled out.. to
figure out if the project is complete or not.. the project is set to
yes or no.

all projects that are marked yes is fine.. but all projects that are
marked no .. the user has to go back and fix.. once the project is
fixed the user has to go back and update the record marking the project
to YES then update. This part is fine..

I wanted to add a checkbox next to the field "project" yes/no ( that is
a combo field) ..

-I went into my table added a field called "fixed" with datatype
"yes/no"
-On my form I added a checkbox field and labeled that "fixed"

In my code I thought I could update as I did the others but i get an
error..

Compile Error:
Method or data member not found

This maybe an easy question but I stated before I new to access to any
help would be appreciated..

Thanks !!

Heres the code if you wanted to look.. again thanks


Code:
--------------------

Private Sub Command62_Click()
Dim f1 As String
Dim f14 As String
'***changed to variant data type
Dim f13 As Variant

ControlNo.SetFocus
f1 = ControlNo.Text & " "
f14 = Fixed.Text
DATECLOSE.SetFocus
'***test to insure DATECLOSE has a value

If Not IsNull(DATECLOSE) And IsDate(DATECLOSE) Then
f13 = DATECLOSE.Text
End If
'***create sql string based on whether f13 is a date or not
If IsDate(f13) Then
strSQL = "UPDATE tblInspections SET tblInspections.Fixed = '" & f14 &
"', tblInspections.DATECLOSE = #" & f13 & "# WHERE tblInspections.ControlNo
= '" & f1 & "'"
Else
strSQL = "UPDATE tblInspections SET tblInspections.Fixed = '" & f14 &
"', tblInspections.dateclose = null WHERE tblInspections.ControlNo = '" & f1
& "'"
 

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