PDA

Click to See Complete Forum and Search --> : Data Environment


opposite99
Sep 20th, 2000, 03:14 AM
Dear Guys, I have a button_click that deals wif the following code

With DataEnvironment1.rscommand1
.Open
.AddNew
End with

Whenever, I pressed the button for the second time, I will surely get an error stated that
The operation requested by the application is not allowed if the object is opened

If i put .close at the below .Addnew . I will get an error msg states
The operation requested by the application is not allowed in this context

How to correct this error, so that no matter how many time i click the button, my code can work?
BTW I have set my command locktype as optimistic

Ur help is deeply appreciated

Jimbob
Sep 20th, 2000, 07:07 AM
I think you have to .Update after you have done .AddNew

opposite99
Sep 20th, 2000, 07:52 PM
Jimbob, my program still gives me the same error msg even though i have put .update . Why do we require .open ? is there any way to make my program work without using .open
?

Feras
Sep 20th, 2000, 09:00 PM
I don't think you need .open because it will open automatically if your for has an object (i.e. TextBox) connected to thet command.
Private Sub cmdNew_click()
DataEnvironment1.rscommand1.AddNew
cmdNew.Enabled = False
cmdUpdate.Enabled = True
End Sub

' Here the user will fill the TextBox which connected to a certain field.

Private Sub cmdUpdate_click()
DataEnvironment1.rscommand1.Update
cmdUpdate.Enabled = False
cmdNew.Enabled = True
End Sub

RIVES
Sep 22nd, 2000, 03:08 PM
Try this...it would surely help.

With DataEnvironment1.rscommand1
IF .state = 0 then .Open
.AddNew
End with