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

update yes/no field using open recordset method

Status
Not open for further replies.

sterlecki

Technical User
Oct 25, 2003
181
US
I have a form where after I input some data there is a command button that will save the record and close the form. I have tried to write code that based on the FracID of the form it will open a record set in another table and change the value of the yes/no field to yes or true.
My code is as follows:

Private Sub cmdCloseDFIT_Click()
On Error GoTo Err_cmdCloseDFIT_Click

'Close the form, update the DFIT table
'and change the FracInfo table field HasDFIT
'to True if a record is present in the DFIT table

Dim rst As DAO.Recordset

Set rst = CurrentDb.OpenRecordset("FracInfo")
rst.Index = "FracID"
rst.Seek "=", "FracID"
rst.Edit
rst!HasDFIT = "True" 'problem occurs here as datatype
'conversion error
rst.Update
DoCmd.Close

Exit_cmdCloseDFIT_Click:
Exit Sub

Err_cmdCloseDFIT_Click:
MsgBox Err.Description
Resume Exit_cmdCloseDFIT_Click

End Sub

I have tried True, Yes, -1, 1 with and without quotes but still get the Datatype conversion error.

What's the problem???
 
Hi!

In this line:

rst.Seek "=", "FracID"

what is "FracID"?



Jeff Bridgham
bridgham@purdue.edu
 
Try
Code:
rst!HasDFIT = TRUE
Your version
Code:
rst!HasDFIT = "True"
is setting it to the character string "True" which is not of type boolean and is giving you a type conversion error.
 
FracID is the field that is common to the two tables.
 
This did not work either. Still getting a Datatype conversion error.

rst!HasDFIT = TRUE
 
Hi!

In that case, in this line:

rst.Seek "=", "FracID"

You must put in a value instead of FracID. Since this is a command button click, I assume that there is a textbox on the form that holds a value:

rst.Seek "=", Me!txtFracID

possibly?

hth


Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top