Results 1 to 5 of 5

Thread: adding problem

  1. #1
    Join Date
    May 2009
    Posts
    17

    Unanswered: adding problem

    Code:
    Dim conMember As ADODB.Connection
    Dim rsMember As ADODB.Recordset
    
    Private Sub cmdAdd_Click()
    If cmdAdd.Caption = "&Add" Then
      adoMember.Recordset.AddNew
      txtMemberID.SetFocus
      cmdSave.Enabled = True
      cmdAdd.Caption = "&Cancel"
      DisableButton
    Else
      adoMember.Recordset.CancelUpdate
      EnableButton
      cmdSave.Enabled = False
      cmdAdd.Caption = "&Add"
    End If
    End Sub
    When i click add, a msg box occurs. Run time error'91': Object variable or with block variable not set.
    How to solve it?
    Attached Thumbnails Attached Thumbnails bookpro.JPG  

  2. #2
    Join Date
    May 2009
    Location
    Philippines
    Posts
    12
    are u already connected to ur database?
    "More Heads Are Better Than One"

  3. #3
    Join Date
    May 2009
    Posts
    17
    Quote Originally Posted by jp26198926
    are u already connected to ur database?
    ya

    Code:
    Private Sub Form_Load()
    Set conMember = New ADODB.Connection
    Set rsMember = New ADODB.Recordset
    
    conMember.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "persist Security Info=false; Data Source =" & App.Path & "\Membership.mdb"
          
    conMember.Open
    With rsMember
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Open "Member", conMember, , , adCmdTable
    End With
    Call LoadMemberRecord
    End Sub

  4. #4
    Join Date
    May 2009
    Location
    Philippines
    Posts
    12
    Quote Originally Posted by ankiesiau
    Code:
    Dim conMember As ADODB.Connection
    Dim rsMember As ADODB.Recordset
    
    Private Sub cmdAdd_Click()
    If cmdAdd.Caption = "&Add" Then
      adoMember.Recordset.AddNew
      txtMemberID.SetFocus
      cmdSave.Enabled = True
      cmdAdd.Caption = "&Cancel"
      DisableButton
    Else
      adoMember.Recordset.CancelUpdate
      EnableButton
      cmdSave.Enabled = False
      cmdAdd.Caption = "&Add"
    End If
    End Sub
    When i click add, a msg box occurs. Run time error'91': Object variable or with block variable not set.
    How to solve it?

    ur adoMember is an Adodc control? if so then.
    u must connect ur some controls to ur adodc

    txtMemberID.Datasource = adoMember
    txtMemberID.Datafield = <name of the fields of ur table>
    Last edited by jp26198926; 05-30-09 at 04:57.
    "More Heads Are Better Than One"

  5. #5
    Join Date
    May 2009
    Posts
    17
    Quote Originally Posted by jp26198926
    ur adoMember is an Adodc control? if so then.
    u must connect ur some controls to ur adodc

    txtMemberID.Datasource = adoMember
    txtMemberID.Datafield = <name of the fields of ur table>
    Thanks you very much.

Posting Permissions

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