By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,224 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,224 IT Pros & Developers. It's quick & easy.

Access Form Locked after linked tables are from sql

P: 12
Hi:
I am experencing very strange case.
I have two identical MS access application, only difference is one backend is MS database, another is MS Sql database.

When I run the application with the sql backend, one form just doesn't allow me to edit, even I can select value from a comboBox control.
(But the application with the MS database backend works fine).

I don't know what will casuse the problem, do I need to do something with the sql data table permmission or what?

Thank you very much.

Jt
Jan 27 '08 #1
Share this Question
Share on Google+
6 Replies


Jim Doherty
Expert 100+
P: 897
Hi:
I am experencing very strange case.
I have two identical MS access application, only difference is one backend is MS database, another is MS Sql database.

When I run the application with the sql backend, one form just doesn't allow me to edit, even I can select value from a comboBox control.
(But the application with the MS database backend works fine).

I don't know what will casuse the problem, do I need to do something with the sql data table permmission or what?

Thank you very much.

Jt
A quickie for you to look at. Do you have your 'primary' key set in the MS SQL database table that the form services?

Jim
Jan 27 '08 #2

P: 12
Hi: Jim
Thank you very much for your reply.
I checked the table in SQL, it has primary key.

I am using this connection:
strSQL = "SELECT actDecsription FROM codAction WHERE actActionID = 3"
rst.Open strSQL, strCnxn, adOpenKeyset, adLockOptimistic
Set Me.Recordset = rst ' trying to recordset to bind the form

On the form, only has a comboBox (name is:"cobBoxDescr"), what I find is:
1. if I add "actDescription" to "Control Source" of the comboBox, the the form becomes read only. (control bound)

But if I
1. leave the "Control Source" of the comboBox empty. (unbound).
2. remove the line: Set Me.Recordset = rst
3. add new line: Me.cobBoxDescr.Value = rst.Fields("actDecsription").Value
Then the form becomes editable.
At least I can make the change (or select other List values from the comboBox dropdown).

Thank you very much.

Jt
Jan 27 '08 #3

P: 12
Hi: Jim

I am trying to do a simple test here: create another combo box, put the combo box Control Source = codAction!actDecsription (using expression builder), when I open the form, the combo box has values, but if i select one of them. on the bottom of the statuse bar says: "Control can't be edited, it's bound to expression "codAction!actDecsription ".

I don't know why that happens.

Thanks.

jt
Jan 27 '08 #4

Jim Doherty
Expert 100+
P: 897
Hi: Jim

I am trying to do a simple test here: create another combo box, put the combo box Control Source = codAction!actDecsription (using expression builder), when I open the form, the combo box has values, but if i select one of them. on the bottom of the statuse bar says: "Control can't be edited, it's bound to expression "codAction!actDecsription ".

I don't know why that happens.

Thanks.

jt

James I'm not quite sure what you re doing here I can see 'now' that you are returning recordset objects and then setting the recordset of the form to the return dataset provided by that SQL. The dropdown I assume you have a different dataset for the rowsource of that?

Anyway in relation to your forms recordset I do not know what method you are using for connection to SQL server but have a look at the MS DataShape method of connection which will allow for your 'editing' needs once the recordset is bound to the form. You must have a reference set to the Microsoft ActiveX Data Objects 2.1 Library

Use this in the on open event of your form and amend the connection string to suit your sql server name relevant user name and password

I suggest to study this method and in particular look at the intentions behind declaring cursors client side and server side. I could go into it for you but could also write a book on it. Have also a look at the HOWTO's on this site where detailed explanations have already been kidly done by other experts on here. In addition I will give you a link to the MS site that explains recordset behaviour in an ODBC context and also the MSDataShape useage to make your recordset editable.

http://support.microsoft.com/kb/227053/EN-US/

Expand|Select|Wrap|Line Numbers
  1.  Dim cn As ADODB.Connection
  2. Dim rs As ADODB.Recordset
  3. Set cn = New ADODB.Connection
  4. With cn
  5.      .Provider = "MSDataShape"
  6.      'The code below uses a sample server name, user ID, and password.
  7.      'Be sure to use your actual server name, user ID, and password.
  8.      .ConnectionString = "DATA PROVIDER=SQLOLEDB;DATASOURCE=yoursqlservername;DATABASE=yourdatabasename;UID=username;PWD=theuserspassword"
  9.      .CursorLocation = adUseServer
  10.      .Open
  11. End With
  12.  
  13. Set rs = New ADODB.Recordset
  14. With rs
  15.      .Source = "SELECT actDescription FROM codAction WHERE actActionID =3"
  16.      .ActiveConnection = cn
  17.      .CursorType = adOpenKeyset
  18.      .LockType = adLockOptimistic
  19.      .Open
  20. End With
  21. Set Me.Recordset = rs
  22. Me.UniqueTable = "codAction"

In addition to this as a point of principle of 'differences in flavour' as to methods of connection and as additional reference material for you to study you also might wish to look at the HOWTO article created by ADezii concerning creation of UDL files for instance to establish SQL server connections in this thread http://www.thescripts.com/forum/thread744230.html

Regards

Jim :)
Jan 27 '08 #5

P: 12
Hi: Jim
Thank you very much for your help.
After another hrs of trying, final I found problem, you are right at the beginning, I didn't set the primary key for the sql table, but I added a primary follow your suggestion immediatly.

But still not working, why? because I should go to the linked table manager and refresh the link.(I didn't realize I should do that).

Everything backs to normal, now the data in the form are editable.

Thanks Jim

jt
Jan 28 '08 #6

Jim Doherty
Expert 100+
P: 897
Hi: Jim
Thank you very much for your help.
After another hrs of trying, final I found problem, you are right at the beginning, I didn't set the primary key for the sql table, but I added a primary follow your suggestion immediatly.

But still not working, why? because I should go to the linked table manager and refresh the link.(I didn't realize I should do that).

Everything backs to normal, now the data in the form are editable.

Thanks Jim

jt
Hi James I,m glad you got it working I wish I'd placed a 6 to 4 bet on the first answer I instinctively gave now haha.

Regards

Jim :)
Jan 28 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.