I am working with unbound forms in an access 2002 frontend connecting to a mysql database server.
I have been able to set the recordset of the unbound form in the form_open sub and reset the recordset as required for filtering/search operations but the access delete option is causing me problems. If the user uses the access delete command on the form it prompts the user to continue the delete or cancel. If the user selects cancel the delete operation is still being carried out. So I guess I have to code for the delete bypassing access entirely. The problem is when I try to get a handle on the recordset currently in the form I am getting an error (#91 Object variable or With Block Variable not Set). The code is as follows:
Dim rst As ADODB.Recordset
Dim conn as ADODB.Connection
Set rst = Me.Recordset
set conn = rst.ActiveConnection
conn.open
rst.Open
Do Until Me.id = rst.Fields("id")
rst.MoveNext
Loop
rst.Delete
rst.Close
conn.Close
set rst = nothing
set conn = nothing
I would appreciate it someone could enlighten me as to how you get a handle and open a connection to a form recordset. I thought this would be straightforward but I am getting nowhere on this.
Thanks!
I have been able to set the recordset of the unbound form in the form_open sub and reset the recordset as required for filtering/search operations but the access delete option is causing me problems. If the user uses the access delete command on the form it prompts the user to continue the delete or cancel. If the user selects cancel the delete operation is still being carried out. So I guess I have to code for the delete bypassing access entirely. The problem is when I try to get a handle on the recordset currently in the form I am getting an error (#91 Object variable or With Block Variable not Set). The code is as follows:
Dim rst As ADODB.Recordset
Dim conn as ADODB.Connection
Set rst = Me.Recordset
set conn = rst.ActiveConnection
conn.open
rst.Open
Do Until Me.id = rst.Fields("id")
rst.MoveNext
Loop
rst.Delete
rst.Close
conn.Close
set rst = nothing
set conn = nothing
I would appreciate it someone could enlighten me as to how you get a handle and open a connection to a form recordset. I thought this would be straightforward but I am getting nowhere on this.
Thanks!