I am using Access2002
I have the following code run when a form opens, and the form won't let me
edit the recordset.
The form and the controls are not locked, edit is allowed, Recordset Type is
'Dynaset'
Any thoughts?
Private Sub Form_Load()
Dim frm As New Form
Dim test As Boolean
Set frm = Me
test = SQLFunctions.BindForm(frm, "DSN=test;uid=admin;pwd=", _
"SELECT LName FROM tblMemberInfo")
Set frm = Nothing
End Sub
Function BindForm(frm As Form, cnConn As String, cmdtext As String) As
Boolean
Dim rstMember As New Recordset
Dim Found As Boolean
Dim i As Integer
Dim cntConn1 As New Connection
Dim cmd As New Command
Dim cntl As Control
Dim fld As Field
'Specify the connect string
cntConn1.ConnectionString = cnConn
'Open the connection
cntConn1.Open
'Specify the SQL statement
cmd.ActiveConnection = cntConn1
cmd.CommandText = cmdtext
'Open the recordset
rstMember.CursorLocation = adUseClient
rstMember.Open cmd, , adOpenStatic, , adCmdText
'set the form's recordset to the returned recordset
Set frm.Recordset = rstMember
'Bind the returned fields to the controls having the same
'name as the field
For Each fld In rstMember.Fields
For Each cntl In frm.Controls
If cntl.Name = fld.Name Then
cntl.ControlSource = fld.Name
End If
Next
Next
'close and destroy the objects used for querying
rstMember.Close
cntConn1.Close
Set rstMember = Nothing
Set cntConn1 = Nothing
Set cmd = Nothing
GetRecords = True
End Function