简体   繁体   中英

Parameterization of a YesNo field using an INSERT INTO in Access VBA

I have an Access Database, I have to do coding in the backend while users will use forms to update records. I have a field that is designated as a YesNo field. Well when I try to parameterize my code I set the parm to YesNo. When I receive the value, it comes in as -1 or (TRUE) like it should. I even tried to hardcode the parm to (TRUE). However when the insert statement executes. My record does not change and when I evaluate it after the run, the value is 0 (False). Help? I can show some of the code later. But I just don't understand, I'm passing the correct information but the insert just isn't changing the field correctly.

This works for me:

Sub TestYesNo
  DIM rs as Recordset
  currentdb.Execute  "CREATE TABLE Tbl1 (YesNoCol BIT)"
  currentdb.Execute "INSERT INTO Tbl1 VALUES(-1)"
  set rs=Currentdb.Openrecordset("Tbl1")
  Debug.print rs!YesNoCol
  rs.close
  currentdb.Execute  "DROP TABLE Tbl1"
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM