Results 1 to 5 of 5

Thread: Data Environment

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    10

    Question

    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

  2. #2
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    I think you have to .Update after you have done .AddNew

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    10
    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
    ?

  4. #4
    Lively Member Feras's Avatar
    Join Date
    Sep 2000
    Location
    Homs, Syria
    Posts
    85

    Talking

    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
    Yesterday is history ... Tomorrow is mistry .. Today is a gift.

    VB6 , intermidiat

  5. #5
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196
    Try this...it would surely help.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width