Vcoderz Community
We create websites that have it all, beauty & brains
Lebanon Web Design & Development - Coddict
 

Go Back   Vcoderz Community > Computer Zone > Computers & Information Technologies

Notices

Computers & Information Technologies « Everything related to computers and internet. »

Reply
 
Share Thread Tools Search this Thread
Old 10-31-2006   #1
mephisto794
Registered Member
 
mephisto794's Avatar
 
Last Online: 04-10-2010
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Question VBA help needed

Hello people !
i have been working on a small MS Access database (stock maintenance and so...)
i am trying to write a code that allows to insert a new 'article' in the 'article' definition table when creating a purchase voucher.

I used this code :
----------------------------------------

Private Sub ArticleID_NotInList(NewData As String, Response As Integer)

a = Split(NewData, "-", , 5)

Dim mrq As String, mdl As String, typ As String, ref As String, coul As String
mrq = a(0)
mdl = a(1)
typ = a(2)
ref = a(3)
coul = a(4)

mrqCriteria = "[MarqueCode] = '" & mrq & "'"
mdlCriteria = "[ModeleCode] = '" & mdl & "'"
typCriteria = "[TypeCode] = '" & typ & "'"

Dim mrqID As Long, mdlID As Long, typID As Long

mrqID = DLookup("[MarqueID]", "tblMarque", mrqCriteria)
mdlID = DLookup("[ModeleID]", "tblModele", mdlCriteria)
typID = DLookup("[TypeID]", "tblType", typCriteria)

sqlArticle = "insert into tblArticle (MarqueID, ModeleID, TypeID, Reference, Couleur) values ( " & mrqID & ", " & mdlID & ", " & typID & ", " & ref & ", " & coul & ") "

DoCmd.RunSQL sqlArticle
Me.Refresh

End If
End Sub

----------------------------------------

am having the following error message : "Run-time error 3134: Syntax error in INSERT INTO statement"

I tried to insert some debugging messages, it showed up that mrqID, mdlID and typID are returning a null value.

Does anyone has any enlightening suggestion ?
am counting on you guys! don't let me down
thanks in advance !


__________________
See you in Baabda dudes!!!
mephisto794 is offline   Reply With Quote
Old 10-31-2006   #2
lebanese_a
Registered Member
 
lebanese_a's Avatar
 
Last Online: 04-15-2018
Join Date: Aug 2006
Posts: 1,549
Thanks: 31
Thanked 213 Times in 151 Posts
Groans: 0
Groaned at 1 Time in 1 Post
Default Re: VBA help needed

Quote:
Originally Posted by mephisto794

sqlArticle = "insert into tblArticle (MarqueID, ModeleID, TypeID, Reference, Couleur) values ( " & mrqID & ", " & mdlID & ", " & typID & ", " & ref & ", " & coul & ") "
Hey
first of all sorry, I am sure you expected a reply that solve ur problem but I am 99% sure that mine is not the one coz I am a beginner at Access (wizards anja2) and a beginner at VB.NET bass from what I know la hala2 that putting stuff entre "" means that the app conciders them as text and I see you got the red part entre guillemet so...
Anyways like I said 99% akid I didn't help bass ya3neh! a7ssan mine ma chi!
lebanese_a is offline   Reply With Quote
Old 11-02-2006   #3
mephisto794
Registered Member
 
mephisto794's Avatar
 
Last Online: 04-10-2010
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Default Re: VBA help needed

Thanks for the tip Lebanese_a.

It helped a little, not enough to resolve the problem though!

I update the insert statement to become as follows :

sqlArticle = "insert into tblArticle (MarqueID, ModeleID, TypeID, Reference, Couleur) values ( & mrqID & , & mdlID & , & typID & , " & ref & ", " & coul & ") "

(Removed the quotes from the ID fields (since they are numeric)

I tried to run the application, no success

A different message though (for a change) : Invalid use of null.

the debugging highlighted the following code :

mrqID = DLookup("[MarqueID]", "tblMarque", mrqCriteria) showing mrqID = 0 (which is not correct)


The message boxes i inserted to show the value of mrqID where not displayed. The system was obviously stopped before reaching them .

Any other suggestions?
__________________
See you in Baabda dudes!!!
mephisto794 is offline   Reply With Quote
Reply

  Vcoderz Community > Computer Zone > Computers & Information Technologies

Tags
needed, vba



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Needed General The Multimedia Room 13 03-30-2007 10:58 AM
help needed badboy_10452 Computers & Information Technologies 4 03-24-2007 06:33 PM
old SL CHI SONG needed cyber88 The Multimedia Room 0 10-31-2006 12:54 AM
help needed Josee The Multimedia Room 2 10-28-2006 07:41 AM
program needed badboy_10452 Computers & Information Technologies 6 06-05-2006 04:27 PM


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


Lebanon web design and development
Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Share