Results 1 to 3 of 3

Thread: Dont know what to do.. Cant get this to work

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2015
    Posts
    1

    Dont know what to do.. Cant get this to work

    Cant get this to work!

    Code:
    Private Sub Command2_Click()
    If (IsNumeric(Price.Text) = False) Then
    MsgBox ("מחיר חייב להכיל ספרות בלבד!")
    Exit Sub
    End If
    
    
    If (IsNumeric(BuyPrice.Text) = False) Then
    MsgBox ("מחיר חייב להכיל ספרות בלבד!")
    Exit Sub
    End If
    
    If (ItemName.Text = "") Then
    MsgBox ("שם לא יכול להשאר ריק")
    Exit Sub
    End If
    
    With Adodc1.Recordset ----------------------------------------------------------------- PROBLEM HERE
    .AddNew
    .Fields("itemname").Value = ItemName.Text
    .Fields("price").Value = Val(Price.Text)
    .Fields("amounthave").Value = x
    .Fields("category").Value = Val(x + 1)
    .Fields("BuyPrice").Value = Val(BuyPrice.Text)
    .update
    End With
    MsgBox " העובד נוסף בהצלחה"
    
    Adodc3.Recordset.AddNew
    With Adodc1.Recordset
    .Fields("ItemName").Value = ItemName.Text
    .Fields("TimeBought").Value = 0
    .update
    End With
    End Sub
    Error Code 91 object variable or with block not set

    I don't know what I do wrong, Would anyone explain to me?

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,477

    Re: Dont know what to do.. Cant get this to work

    Sounds like there is no recordset assigned to the Adodc1 control. I am assuming the control does exist and is not named incorrectly.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,278

    Re: Dont know what to do.. Cant get this to work

    I would suspect this line as it looks totally out of place there
    Code:
    Adodc3.Recordset.AddNew
    should that be adodc1 ?

    Edit: Sorry did not see that part that said problem here as it was to far right to show in the window. Still the adodc3 looks suspicious there, perhaps a second problem

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