 |
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
|
|
|

December 26th, 2006, 11:16 AM
|
Registered User
|
|
Join Date: Oct 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

December 28th, 2006, 06:16 PM
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |