add not working with datacombo

giana
01-12-2004, 09: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)
ConnectBackend
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
Next

'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"
.Refresh
End With

mbDataChanged = False
Handler:
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
.AddNew

lblStatus.Caption = "Add record"
mbAddNewFlag = True

SetButtons False
End With
Exit Sub

AddErr:
MsgBox Err.Description
End Sub

thanks a lot
giana

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

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q195/6/38.asp&NoWebContent=1


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

giana
01-12-2004, 10: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
giana

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum