Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert record

Status
Not open for further replies.

madhula

Programmer
Apr 17, 2006
17
US
Dim CurrentLevel As Integer
Dim CurrentDeptId As Variant

Dim LevelUp1 As Variant
Dim LevelUp2 As Variant
Dim LobId As Variant
Dim AttId As Integer
Dim Oc_Id As Integer
Dim LevelCheck As Boolean

Set rst_check = dbs.OpenRecordset("Select dept_level,deptid from sysNewDepartments ")
Do Until rst_check.EOF
CurrentLevel = rst_check("dept_level")
CurrentDeptId = rst_check("deptid")
AttId = 2
Oc_Id = 5
LevelCheck = False

If CurrentLevel = 5 Then
LobId = "L" & 5 & "_DEPTID"
Else
LobId = CurrentLevel
End If

LevelUp1 = "L" & CurrentLevel - 1 & "_DEPTID"
LevelUp2 = "L" & CurrentLevel - 2 & "_DEPTID"
If rst_check("dept_level") <= 6 Then

dbs.Execute ("INSERT INTO sysDeptDef (DeptId,DeptId_Up1,DeptId_Up2,AttId,LobId,Level,Oc_id,LevelCheck) VALUES (" & _
CurrentDeptId & "," & LevelUp1 & "," & LevelUp2 & "," & AttId & "," & LobId & "," & CurrentLevel & "," & Oc_Id & "," & LevelCheck & ")")
End If
rst_check.MoveNext
Loop
rst_check.Close


I am using the above code to insert record.Process fails at insert command.Can anyone suggest where i am going wrong.i ahven'e used vba in years.
Please help
 
i have used
dbs.Execute ("INSERT INTO sysDeptDef (DeptId,DeptId_Up1,DeptId_Up2,AttId,LobId,Level,oc_id,LevelCheck) VALUES ('" & CurrentDeptId & "','" & LevelUp1 & "','" & LevelUp2 & "'," & AttId & ",'" & LobId & "'," & CurrentLevel & "," & Oc_Id & ",'" & LevelCheck & "')")


it still fails..:(

any suggestions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top