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

stumped on INSERT INTO statement

Status
Not open for further replies.

Hildegoat15

Technical User
Aug 3, 2001
38
CA
Hi,

i've made a form which allows people to transfer region (RHA) or CPL. Based on the transfer they want to do, i run the appropriate INSERT INTO statment to add a record to the Transfer History table, putting nulls into the fields which aren't applicable. It works fine for the RHA transfer, but the CPL gives me an error saying :

Too few parameters. expected 2.

my insert statements look like this. the first one is the one that works:

CurrentDb.Execute "INSERT INTO Transfer(ClientID, OldRHA, NewRHA, OldCPL, NewCPL, TransferDate) VALUES ('" & Me!txtClientID & "', " & Me!txtOldRHA & ", " & Me!txtNewRHA & ", null, null, #" & Format(Me!txtTransferDate, "mm/dd/yyyy") & "#);", dbFailOnError


This one doesn't:

CurrentDb.Execute "INSERT INTO Transfer(ClientID, OldRHA, NewRHA, OldCPL, NewCPL, TransferDate) VALUES ('" & Me!txtClientID & "', null, null, " & Me!txtOldArea & ", " & Me!txtNewArea & ", #" & Format(Me!txtTransferDate, "mm/dd/yyyy") & "#);", dbFailOnError


since RHA is a numeric field, i tried putting zeroes instead of nulls, but i get the same error. CPL is a text field, by the way. I'm thinking a fresh set of eyes could help me out, so if you see any way i could fix my error, it'd be much appreciated. -Matt
 
I can't see this causing that error, but I noticed that you're missing ' with the CPL values in the second statement (around Me!txtOldArea & Me!txtNewArea).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top