paulsmoothcurt
Programmer
Hi there,
I have a form, that was bound to a table residing locally whilst developing.
Now the active tables are in SQL server, and I have removed the table locally. The form has been set unbound, and instead I connect to SQL server with the forms open event (code below) using ADO and recordset. I would have preferred recordsource (is it possible without local or linked tables?) but I do not want the tables to be visible. Currently reworking the entire app as an Access project, and will set table security later, but need a certain element of the app working asap. So, I need the recordset(if no choice of recordsource) to work in such a way that it will only add a new record,not edit current ones. The form is set to DataEntry mode, but it still doesnt work?
Also, currently some actions are carried out by queries, can I also code the queries in a module, and set a connection for them to the server? If not, I'm forced to use the app as it is, until the adp is finished?
Code:
Dim Conn As ADODB.connection
Dim rst1 As ADODB.Recordset
Set Conn = New ADODB.connection
Conn.Open "Provider=sqloledb;" & _
"Data Source=SERVER;" & _
"Initial Catalog=DATA;" & _
"Integrated Security=SSPI"
Set rst1 = New ADODB.Recordset
With rst1
Set .ActiveConnection = Conn
.Source = "SELECT * FROM ORDERS WHERE DocumentType=1;"
.LockType = adLockOptimistic
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.Open
.AddNew
End With
Set Me.Recordset = rst1
Any suggestions very gratefully received.
Thanks in advance
I have a form, that was bound to a table residing locally whilst developing.
Now the active tables are in SQL server, and I have removed the table locally. The form has been set unbound, and instead I connect to SQL server with the forms open event (code below) using ADO and recordset. I would have preferred recordsource (is it possible without local or linked tables?) but I do not want the tables to be visible. Currently reworking the entire app as an Access project, and will set table security later, but need a certain element of the app working asap. So, I need the recordset(if no choice of recordsource) to work in such a way that it will only add a new record,not edit current ones. The form is set to DataEntry mode, but it still doesnt work?
Also, currently some actions are carried out by queries, can I also code the queries in a module, and set a connection for them to the server? If not, I'm forced to use the app as it is, until the adp is finished?
Code:
Dim Conn As ADODB.connection
Dim rst1 As ADODB.Recordset
Set Conn = New ADODB.connection
Conn.Open "Provider=sqloledb;" & _
"Data Source=SERVER;" & _
"Initial Catalog=DATA;" & _
"Integrated Security=SSPI"
Set rst1 = New ADODB.Recordset
With rst1
Set .ActiveConnection = Conn
.Source = "SELECT * FROM ORDERS WHERE DocumentType=1;"
.LockType = adLockOptimistic
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.Open
.AddNew
End With
Set Me.Recordset = rst1
Any suggestions very gratefully received.
Thanks in advance