Access 2000 to SQL Server 2000 conversion for Boolean fields

  • Thread starter Thread starter Dave - daking
  • Start date Start date
D

Dave - daking

I recently converted an Access 2000 backend to a SQL
Server 2000 database with minimal problems. However when
I made some changes to a form in the Access front end and
compiled the VB code behind the form I received the
following error message indicating a problem with
Me.GroupTogether:

"Method or Data member not found"

The procedure listed below generated the above error
message:

Private Sub CmdChangeGrpTogeth_Click()
Dim currRec As Long
'Original module

currRec = Me.CurrentRecord

If Me.GroupTogether = True Then
Me.GroupTogether = False
Else
Me.GroupTogether = True
End If
DoCmd.Requery

DoCmd.GoToRecord , , acGoTo, currRec
End Sub

The GroupTogether is a column in the table behind the form
with datatype Yes/No. Is there an alternative way to
handle the above situation?
 
Dave said:
I recently converted an Access 2000 backend to a SQL
Server 2000 database with minimal problems. However when
I made some changes to a form in the Access front end and
compiled the VB code behind the form I received the
following error message indicating a problem with
Me.GroupTogether:

"Method or Data member not found"
The GroupTogether is a column in the table behind the form
with datatype Yes/No. Is there an alternative way to
handle the above situation?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Usually, your method, using the period, should work if the data member
is in the form's RecordSource. Check the RecordSource for a column
(data member) named "GroupTogether" and that it is spelled correctly.
Perhaps during the conversion from Access to SQL server the link to the
Access front-end has dropped the column GroupTogether. Try re-linking
the table.

Using a period between Me and GroupTogether means that GroupTogether is
a property/method of the referenced form (Me). To refer to values in
controls the recommended method is to use an exclamation point between
the form reference and the control name: Me!GroupTogether, providing
there is a control named GroupTogether. To avoid confusion I usually
put all data members on the form, as controls (setting Visible = False
when the control value is not necessary to the user) and refer to them
using the exclamation point method.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQHWiBYechKqOuFEgEQLV8gCdG56I3yxORpCDmsJz8++uUJvaJjwAoMsb
u6MR/t00bS1hT8KSkFfnQOmX
=OSnb
-----END PGP SIGNATURE-----
 
The problem is Boolen values in SQL Server are "bit" data types and can only
be 1 (for True) or 0 (for False). True in VBA however is defined as -1,
*not* 1. Your If-Then statement is also very inefficient coding. Why not
write it this way, which BTW will work for either .MDB or SQL Server *and*
is very efficient code. I cut and pasted your code with the '>' still in; my
line doesn't have the '>'. Also, I replaced the '.' with a '!'; I'm not sure
the dot is the correct operator.
Private Sub CmdChangeGrpTogeth_Click()
Dim currRec As Long
'Original module

currRec = Me.CurrentRecord
'change to this!

Me!GroupTogether = Not Me!GroupTogether
 
Back
Top