Link to home
Start Free TrialLog in
Avatar of Lawrence Salvucci
Lawrence SalvucciFlag for United States of America

asked on

Append Query from Access to SQL Server Backend

I am trying to run an append query from my access db to a linked BE table that is in SQL server. Whenever I try to run the append query I get an error stating "You tried to assign the Null value to a variable that is not a Variant data type". What exactly does this mean? Every field I am trying to append data to has a value so I'm not sure what it means by this error. Can anyone shed some light on this?
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lawrence Salvucci

ASKER

I'll double check the data but I went through it already and every field had a value. There are some fields that I am not appending data to but those fields are NOT in the append query. If those fields are set to NOT "Allow Nulls" in SQL would it not allow the record to be appended? I wondered if that could be the cause too. I will double check the data again and make sure every field has a value in it. I am inserting it into an actual table, not a view. I know that for a fact. If my destination table had a trigger, would there be a way to disable the trigger from access in order to run the append?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am not doing this via VBA. I am using an append query straight from the queries, not via VBA.
Can you show the SQL of your append query?
Sure...

INSERT INTO dbo_qtmast2 ( fcompany, fquoteno, fackdate, fccurid, fcfactor, fcfname, fcfromno, fcfromtype, fcity, fcountry, fdatedue, fdaterecvd, fdcurdate, fdexpired, fdistno, fdsalespn, fduplicate, festimator, ffax, fjobname, fcsoldto, fcustno, fnextenum, fnextinum, fordpotent, fordtime, fphone, fprint_dt, fprinted, fquotecopy, fquotedate, fquoteto, frequestno, frevno, fsalespn, fstate, fstatus, ftype, fzip, fcusrchr1, fcusrchr2, fcusrchr3, fnusrqty1, fnusrcur1, fdusrdate1, fdisrate, fterm, fpaytype, fdeurodate, feurofctr, fusercode, fcshipto, fltotal, fclosmemo, fmstreet, fmusermemo, fsalumemo, fccontkey, flcontract, fndbrmod, ContractNu, OpportunNum, ModifiedDate, OppCrType, CreatedDate, fbilladdr )
SELECT dbo_qtmast1.fcompany, dbo_qtmast1.fquoteno, dbo_qtmast1.fquotedate, "USD" AS fccurid1, "1.00000" AS fcfactor1, dbo_qtmast1.fcfname, dbo_qtmast1.fcfromno, dbo_qtmast1.fcfromtype, dbo_qtmast1.fcity, dbo_qtmast1.fcountry, dbo_qtmast1.fdatedue, dbo_qtmast1.fquotedate, dbo_qtmast1.fdcurdate, dbo_qtmast1.fdexpired, dbo_qtmast1.fdistno, dbo_qtmast1.fdsalespn, dbo_qtmast1.fduplicate, dbo_qtmast1.festimator, dbo_qtmast1.ffax, dbo_qtmast1.fjobname, dbo_qtmast1.fcsoldto, dbo_qtmast1.fcustno, dbo_qtmast1.fnextenum, dbo_qtmast1.fnextinum, dbo_qtmast1.fordpotent, dbo_qtmast1.fordtime, dbo_qtmast1.fphone, dbo_qtmast1.fprint_dt, dbo_qtmast1.fprinted, dbo_qtmast1.fquotecopy, dbo_qtmast1.fquotedate, dbo_qtmast1.fquoteto, dbo_qtmast1.frequestno, dbo_qtmast1.frevno, dbo_qtmast1.fsalespn, dbo_qtmast1.fstate, dbo_qtmast1.fstatus, dbo_qtmast1.ftype, dbo_qtmast1.fzip, dbo_qtmast1.fcusrchr1, dbo_qtmast1.fcusrchr2, dbo_qtmast1.fcusrchr3, dbo_qtmast1.fnusrqty1, dbo_qtmast1.fnusrcur1, dbo_qtmast1.fdusrdate1, dbo_qtmast1.fdisrate, dbo_qtmast1.fterm, dbo_qtmast1.fpaytype, dbo_qtmast1.fdeurodate, dbo_qtmast1.feurofctr, dbo_qtmast1.fusercode, dbo_qtmast1.fcshipto, dbo_qtmast1.fltotal, dbo_qtmast1.fclosmemo, dbo_qtmast1.fmstreet, dbo_qtmast1.fmusermemo, dbo_qtmast1.fsalumemo, dbo_qtmast1.fccontkey, dbo_qtmast1.flcontract, dbo_qtmast1.fndbrmod, dbo_qtmast1.ContractNu, dbo_qtmast1.OpportunNum, dbo_qtmast1.ModifiedDate, dbo_qtmast1.OppCrType, dbo_qtmast1.CreatedDate, dbo_qtmast1.fbilladdr
FROM dbo_qtmast1
WHERE (((dbo_qtmast1.fquoteno)=[Forms]![frmQuoteMain]![txtRecordID]));

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, Dale. That was one of my concerns as to why it won't append to the table. Since I don't have all the fields in my append query I was thinking it wouldn't allow null values for fields that I don't have in my query. I'll review this as well.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's what I am going to test out tomorrow. I am going to add every field that is required and then try again. Will post back with my results.
I found the problem. Some of my datatypes in Access were set to Yes/No when I imported the data structure from SQL. Those same datatypes were set to bit in SQL so the datatypes weren't 'clicking' together. So I changed those and made sure every field that was required had data in it and the append query is working now. Thank you to everyone for your help! I greatly appreciate it as always!!