PC Review


Reply
Thread Tools Rate Thread

Createquerydef

 
 
New Member
Join Date: Jun 2009
Posts: 2
 
      3rd Jun 2009
I'm using createquerydef to insert 2 similiar records into my trans table. The second record is overwriting the first. When I step thru the code, it doesn't overwrite. Tried lots of things but nothing works!

Dim qdefr As DAO.QueryDef
Dim strRDY As String
Set db = CurrentDb()

'creating (change trans record) to support updated barcode field change
strRDY = "INSERT INTO TRANS (model_num, trans_type, serial_num, cond_rcvd," & _
"delay_reason, ecn, subcust_cd, icn, compl_dt, nomen, apprv_procd, srvc_label," & _
"equip_type, mfr_cd, on_site, srvc_lab, metrl_cycle, cal_lab_std, next_due_dt," & _
"recall_dt, wl_norm_hrs, phase_id, sched_lab, cust_cd, metercard_flag, spcl_inst," & _
"shop_inv, block92, std_class, bar_cd, time_stamp )SELECT inv.model_num," & _
"'chg', inv.serial_num, inv.cond_rcvd, inv.delay_reason, inv.ecn," & _
"inv.subcust_cd, inv.icn, inv.compl_dt, inv.nomen, inv.apprv_procd, inv.srvc_label," & _
"inv.equip_type, inv.mfr_cd, inv.on_site, inv.srvc_lab, inv.metrl_cycle," & _
"inv.cal_lab_std, inv.next_due_dt, inv.recall_dt, inv.wl_norm_hrs, inv.phase_id," & _
"inv.sched_lab, inv.cust_cd, inv.metercard_flag, inv.spcl_inst, inv.shop_inv," & _
"inv.block92, inv.std_class, inv.bar_cd, Now() AS expr FROM inv INNER JOIN tmptbl " & _
"ON inv.ecn = tmptbl.ecn"
Set qdefr = CurrentDb.CreateQueryDef("", strRDY)
qdefr.Execute
qdefr.Close

Set qdefr = Nothing
Set db = Nothing

'creating (receipt trans record) to support updated barcode field change
strRDY = "INSERT INTO TRANS ( model_num, trans_type, shop_num, cal_job_ord," & _
"rep_job_ord, mod_job_ord, rcvd_dt, serial_num, cond_rcvd, delay_reason, ecn," & _
"subcust_cd, icn, compl_dt, nomen, apprv_procd, srvc_label, equip_type, mfr_cd," & _
"on_site, srvc_lab, metrl_cycle, cal_lab_std, next_due_dt, recall_dt, wl_norm_hrs," & _
"phase_id, sched_lab, cust_cd, metercard_flag, spcl_inst, shop_inv, block92," & _
"std_class, bar_cd, time_stamp )SELECT inv.model_num, 'rec', inv.shop_num," & _
"inv.cal_job_ord, inv.rep_job_ord, inv.mod_job_ord, inv.rcvd_dt, inv.serial_num," & _
"inv.cond_rcvd, inv.delay_reason, inv.ecn, inv.subcust_cd, inv.icn, inv.compl_dt," & _
"inv.nomen, inv.apprv_procd, inv.srvc_label, inv.equip_type, inv.mfr_cd," & _
"inv.on_site, inv.srvc_lab, inv.metrl_cycle, inv.cal_lab_std, inv.next_due_dt," & _
"inv.recall_dt, inv.wl_norm_hrs, inv.phase_id, inv.sched_lab, inv.cust_cd," & _
"inv.metercard_flag, inv.spcl_inst, inv.shop_inv, inv.block92, inv.std_class," & _
"inv.bar_cd, Now() AS expr FROM inv INNER JOIN tmptbl ON inv.ecn = tmptbl.ecn"

Set qdefr = CurrentDb.CreateQueryDef("", strRDY)
' db.QueryTimeout = 20
qdefr.Execute
qdefr.Close
Set qdefr = Nothing
Set db = Nothing
 
Reply With Quote
 
 
 
 
New Member
Join Date: Jun 2009
Posts: 2
 
      4th Jun 2009
I put in a msgbox between the two inserts and everything is working. Comments?
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CreateQueryDef JimP Microsoft Access VBA Modules 6 10th Apr 2007 05:21 PM
CreateQueryDef =?Utf-8?B?U3RldmVu?= Microsoft Access VBA Modules 3 11th Mar 2007 02:58 PM
CreateQueryDef Problem =?Utf-8?B?Q2hyaXMgR3V5bm4=?= Microsoft Access 2 17th Nov 2006 05:48 PM
question about CreateQueryDef Daama via AccessMonster.com Microsoft Access Form Coding 1 6th Jun 2006 02:10 AM
CreateQueryDef question =?Utf-8?B?SmVmZkg=?= Microsoft Access VBA Modules 4 24th Mar 2006 04:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:46 AM.