add not working with datacombo

01-12-2004, 10:28 AM
Hi everybody, this is my problem for today:
I have a form in vb6 called employees, which gets its data from an access db through an Ado connection. The form has a datacombo, called "Departments", which takes the ID from the Employee table, but the name of the department from the Departments table. It works fine when I browse the employee table through the form, but when I try to add a record I get an erro back: "Consumer's event handler called a non-reentrant method in the provider". Anyone knows what this means?
here's the code for the form_load event and the add event:

Private Sub Form_Load()
On Error GoTo Handler:

Call CenterForm(Me)
Dim depRecSet As Recordset

Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "SELECT Name,Title,DepartmentID,Address,City,StateorProvince,PostalCode,EmailN ame,HomePhone,SocialSecurityNumber,DateHired,HourlyRate FROM Employees", conData, adOpenStatic, adLockOptimistic

Dim oText As TextBox 'Bind the text boxes to the data provider
For Each oText In Me.txtFields
Set oText.DataSource = adoPrimaryRS

'Fill the department combobox from the department table and write the user choice in the employees table

Set depRecSet = New Recordset
depRecSet.Open "SELECT DepartmentID, DepartmentName FROM Departments", conData, adOpenStatic, adLockOptimistic
With Me.cmbDepartment
Set .DataSource = adoPrimaryRS
.DataField = "DepartmentID"
.BoundColumn = "DepartmentID"

Set .RowSource = depRecSet
.ListField = "DepartmentName"
End With

mbDataChanged = False
Err.Number & Err.Description
End Sub

Private Sub cmdAdd_Click()
On Error GoTo AddErr

With adoPrimaryRS
If Not (.BOF And .EOF) Then
mvBookMark = .Bookmark
End If

lblStatus.Caption = "Add record"
mbAddNewFlag = True

SetButtons False
End With
Exit Sub

MsgBox Err.Description
End Sub

thanks a lot

01-12-2004, 11:06 AM
Try this link...I think it should help

Let me know if it helps......

01-12-2004, 11:23 AM
hey, thanks a lot. I'm not using the datacontrol, but the process is the same

myrecordset.Move 0

in the update button

Thank you very much

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum