Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 26th, 2006, 11:16 AM
Registered User
 
Join Date: Oct 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with SQL Insert statement in VBA Code

I have a piece of VBA code in which I am having some trouble with a simple SQL insert statement. I believe the problem comes from syntax at the end of the first line (though I may be wrong). I am hoping that someone can give me a hand here:
Code:
sql = "insert into dbo_tbl_Call (Member_Number,CallDate,Question,Answer,StartTime,StopTime,CallDurationMinutes,Commission,CommissionBetweenBrokers,CommissionBetweenBrokersandAgents,CommissionBetweenBrokersandSellerBuyers,CommissionRipoff,RebateNegotiationOfCommission,CommissionOther,LicenseLaw,LicenseLawAdvertising,LicenseLawOwnership,LicenseLawChangingBrokers,LicenseLawExclusiveListing,LicenseLawContinuingEducation,LicenseLawLLC,HowTo_LicenseLaw,PersonalAssistant,LicenseLawOther,FairHousing,FairHousingDiscrimination,FairHousingOther,Contract,ListingAgreement,ContractBinder,ContractPurchaseOffer,ContractMultipleCompetingOffers,ContractDepositsEscrow,ContractOther,Disclosure,DisclosureBrokerStatusAgency,DisclosurePropertyCondition,DisclosureSexOffender, _
DisclosureLeadPaint,DisclosureOther,Agnecy,BrokersAgency,SellersAgent,BuyersAgent,ChangingAgency,AgencyOther,DOS,ChangingBrokers,ComplaintForViolation,DOSother,Referrals,NonLicensees,Licensees,OutOfStateBrokers,ReferralsOther,Arbitration,ArbitrationArbitrableIssue,ArbitrationCurrentlyInArbitration,ArbitrationArbitrationCompletedAppeal,ArbitrationCompliance,ArbitrationOther,CodeOfEthics,CCodeOfEthicsViolation,CodeOfEthicsProcess,CodeOfEthicsDecision,CodeOfEthicsAppeal,CodeOfEthicsOther,BoardAssociation,MembershipIssue,ElectionIssue,ReferralAgent,BoardAssociationOther,MLS,MLSVOW,MLSIDX,MLSPolicy,MLSother,OtherHotlineIssue,DoNotCall,DoNotFax,CANSPAM,RESPA,MortgageBroker,IndependentContractor,AntiTrust,Other) " & _
"values " & _
"(" & Me.Member_Number & ",#" & Me.CallDate & "#,'" & Replace(Me.Question, "'", "''") & "','" & Replace(Me.Answer, "'", "''") & "',#" & Me. _
StartTime & "#,#" & Me.EndTime & "#," & CallDurationMinutes & _
"," & Commission & "," & CommissionBetweenBrokers & "," & CommissionBetweenBrokersandAgents & "," & CommissionBetweenBrokersandSellerBuyers & "," & CommissionRipoff & "," & RebateNegotiationOfCommission & "," & CommissionsOther & "," & LicenseLaw & "," & LicenseLawAdvertising & "," & LicenseLawOwnership & "," & LicenseLawChangingBrokers & "," & LicenseLawExclusiveListing & "," & LicenseLawContinuingEducation & "," & LicenseLawLLC & "," & _
HowTo_LicenseLaw & "," & PersonalAssistant & "," & LicenseLawOther & "," & FairHousing & "," & FairHousingDiscrimination & "," & FairHousingOther & "," & Contract & "," & ListingAgreement & "," & ContractBinder & "," & ContractPurchaseOffer & "," & ContractMultipleCompetingOffers & "," & ContractDepositsEscrow & "," & ContractOther & "," & Disclosure & "," & DisclosureBrokerStatusAgency & "," & DisclosurePropertyCondition & "," & DisclosureSexOffender & "," & _
DisclosureLeadPaint & "," & DisclosureOther & "," & Agency & "," & BrokersAgency & "," & SellersAgent & "," & BuyersAgent & "," & ChangingAgency & "," & AgencyOther & "," & DOS & "," & ChangingBrokers & "," & ComplaintForViolation & "," & DOSother & "," & Referrals & "," & NonLicensees & "," & Licensees & "," & OutOfStateBrokers & "," & ReferralsOther & "," & _
Arbitration & "," & ArbitrationArbitrableIssue & "," & ArbitrationCurrentlyInArbitration & "," & ArbitrationArbitrationCompletedAppeal & "," & ArbitrationCompliance & "," & ArbitrationOther & "," & CodeOfEthics & "," & CodeOfEthicsViolation & "," & CodeOfEthicsProcess & "," & CodeOfEthicsDecision & "," & _
CodeOfEthicsAppeal & "," & CodeOfEthicsOther & "," & BoardAssociation & "," & MembershipIssue & "," & ElectionIssue & "," & ReferralAgent & "," & BoardAssociationOther & "," & MLS & "," & MLSVOW & "," & MLSIDX & "," & MLSPolicy & "," & MLSOther & "," & OtherHotlineIssue & "," & DoNotCall & "," & DoNotFax & "," & CANSPAM & "," & RESPA & "," & MortgageBroker & "," & IndependentContractor & "," & AntiTrust & "," & Other & ")"
Thanks in advance for any help you might be able to offer!

Austin Moran

 
Old December 28th, 2006, 06:16 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is a sample piece of code I have used that works.

        DoCmd.RunSQL ("INSERT INTO tbl_os_seq ( LOGO, YEAR, OCC, [WHLSL PACK], [WHLSL AGIN], [WHLSL AGIN DESC], HOLIDAY, PLG, [PLG DESCRIPTION]) " _
               & " SELECT tbl_import.LOGO, tbl_import.YEAR, tbl_import.OCC, tbl_import.[NEW SEQ], tbl_import.OVERSIZED, tbl_import.[MARKETING NUMBER], tbl_import.[WHLSL AGIN DESC], tbl_import.HOLIDAY, tbl_import.PLG, tbl_import.[PLG DESCRIPTION] " _
               & " From tbl_import WHERE tbl_import.OCC = " & occasion_lkup & "ORDER BY tbl_import.OVERSIZED, tbl_import.[NEW SEQ]")

HTH,

Dave






Similar Threads
Thread Thread Starter Forum Replies Last Post
T-SQL statement causing error with insert/update saf SQL Language 0 September 7th, 2007 04:48 PM
Creating an INSERT INTO SQL statement for 2 tables sburgess Access 1 April 18th, 2007 08:52 AM
Unsuccessfuly execution of SQL statement in VBA cindyzhou Access VBA 0 January 1st, 2006 10:58 PM
Unsuccessful execution of SQL statement within VBA cindyzhou Pro VB Databases 0 January 1st, 2006 10:55 PM
SQL Insert statement with apostrophe xgbnow SQL Language 11 June 18th, 2003 08:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.