By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

Insert unbound form fields to table

P: 11
Hello, I am trying to run a query that will help me insert unbound form fields to a database table. I have basically created a form that will allow users to select the columns (with tons of help from you guys) and would now like to have a main form that will input new search parameters as a record that can be queried later to rerun previous reports. All of my checkbox fields are being inserted into the table but it seems to be treating my text boxes as parameters. How can I get this query to work without converting textbox fields to parameters in the process? The code that I am using is below:


Expand|Select|Wrap|Line Numbers
  1. InsSQL = "INSERT INTO tbl_setup_detail ([RunID], [Template], [filename], [split_field], [LaneID], [RefNum], [OFacility], [OCity], [OState], [OZip], [ORegion], [OCountry], [DFacility], [DCity], [DState], [DZip], [DRegion], [DCountry], [Distance], [AnnualVol], [CarName], [CarRef], [Mode], [Equip], [EquipSize], [OrBid], [OrRateType], [OrMinChge], [OrTotalRate], [AssetType], [AllocAmount], [RateGuideSeq], [AwardType]) " & _
  2.      "VALUES (" & _
  3.      Me.txtRunID & _
  4.      "," & Me.txtTemplate & "," & Me.txtFilename & "," & Me.txtSplitfield & "," & Me.ckLaneID & "," & Me.CkRefNum & "," & Me.CkOfacility & "," & Me.CkOCity & _
  5.      "," & Me.CkOState & "," & Me.ckOZip & "," & Me.ckOregion & "," & Me.ckOCountry & "," & Me.ckDFacility & "," & Me.ckDCity & "," & Me.ckDState & "," & Me.ckDZip & _
  6.      "," & Me.ckDRegion & "," & Me.ckDCountry & "," & Me.ckDistance & "," & Me.ckAnnualVol & "," & Me.ckCarName & "," & Me.ckSCAC & "," & Me.ckTransMode & _
  7.      "," & Me.ckEquip & "," & Me.ckEquipSize & "," & Me.ckOrBid & "," & Me.ckRateType & "," & Me.ckMinChge & "," & Me.ckTotalRate & "," & Me.ckAssetType & _
  8.      "," & Me.ckAllocAmount & "," & Me.ckRouteGuideSeq & "," & Me.ckAwardType & ");"
  9.  
  10. Debug.Print InsSQL
  11.  
  12. CurrentDb.Execute (InsSQL)
  13.  
Feb 5 '14 #1

✓ answered by Rabbit

Textboxes hold strings and strings need to be encapsulated in quotes.

Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,366
Textboxes hold strings and strings need to be encapsulated in quotes.
Feb 5 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.