November 14th, 2012, 07:54 PM
#1
Insert data = 0
I am trying to use Insert Statement which is one of the field(format = Number) in Access = 0. My program does not understand data which is one of the field = 0. Can you help me to solve the problem.
I am appreciate for your help !!!!!!!
Attached Files
November 14th, 2012, 09:17 PM
#2
Re: Insert data = 0
If it exists, then you cannot insert it. Otherwise, it may start with 1, so I'd try that first.
November 14th, 2012, 09:50 PM
#3
Re: Insert data = 0
I have to insert 2 way : if it exist or not.
November 15th, 2012, 01:40 AM
#4
Re: Insert data = 0
Post your code around the INSERT (and use CODE TAGS, please).
November 15th, 2012, 08:08 AM
#5
Re: Insert data = 0
Code:
Dim diem as Double
If (ws.Range("F" & i).Value = NULL) Then
diem = 0
Else
diem = ws.Range("F" & i).Value
End If
con.Execute "INSERT INTO SV([No],MSSV,MaLop,Ho,Ten,Diem,HanhKiem,[User],Status,[Date]) VALUES ('" & rs("MaxField") + 1 & "','" & ws.Range("C" & i).Value & "','" & ws.Range("A" & i).Value & "','" & ws.Range("D" & i).Value & "','" & ws.Range("E" & i).Value & "','" & ws.Range("F" & i).Value & "','" & tenUser & "','" & "-1" & "','" & NgayGioDangNhap & "')"
November 15th, 2012, 01:06 PM
#6
Re: Insert data = 0
I can't even begin to understand the question, you'll need to do a better job of explaining what you are trying to do and what problem you are having. Also need to tell us what field and what the data type is of that field in the database.
Always use [code][/code] tags when posting code.
November 15th, 2012, 01:10 PM
#7
Re: Insert data = 0
Try printing the value of the query, and putting that into ACCESS
Code:
Dim Query as String
Query = "INSERT INTO SV([No],MSSV,MaLop,Ho,Ten,Diem,HanhKiem,[User],Status,[Date]) VALUES ('" & rs("MaxField") + 1 & "','" & ws.Range("C" & i).Value & "','" & ws.Range("A" & i).Value & "','" & ws.Range("D" & i).Value & "','" & ws.Range("E" & i).Value & "','" & ws.Range("F" & i).Value & "','" & tenUser & "','" & "-1" & "','" & NgayGioDangNhap & "')"
Debug.Print Query
stop
' after it works in access, use this:
con.Execute Query ' and it should work
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
On-Demand Webinars (sponsored)