Results 1 to 4 of 4
  1. #1
    lukusm's Avatar
    lukusm is offline Novice
    Windows 7 Access 2007
    Join Date
    Jan 2010
    Location
    Lodz, Poland
    Posts
    9

    Unhappy Problem with vba error

    Hello,

    I have big problem with vba code. I try to update table in my database with one of the forms. I have form called Insert Person on which I have 5 fields - name, surname, street, postal code and city. And below them a button "add person" coded with VB.

    I don't know why the VB shows me an error "Object required".

    Here's a code of the button:
    Code:
    Option Compare Database
    
    Private Sub WstawBtn_Click()
    On Error GoTo Err_WstawBtn_Click
    
    
        Dim baza As DAO.Database
        Dim rekord As DAO.Recordset
        Set baza = CurrentDb()
        Set rekord = db.OpenRecordset("Klienci", dbOpenDynaset)
        Dim imieVar As String
        Dim nazwiskoVar As String
        Dim ulicaVar As String
        Dim kodVar As String
        Dim miejscowoscVar As String
        imieVar = Me.ImieTxt
        nazwiskoVar = Me.NazwiskoTxt
        ulicaVar = Me.UlicaTxt
        kodVar = Me.KodTxt
        miejscowoscVar = Me.MiejscowoscTxt
        
        rekord.AddNew
        rekord![Imię] = imieVar
        rekord![Nazwisko] = nazwiskoVar
        rekord![Ulica] = ulicaVar
        rekord![Kod_pocztowy] = kodVar
        rekord![Miejscowość] = miejscowoscVar
        rekord.Update
        
    
    Exit_WstawBtn_Click:
        Exit Sub
    
    Err_WstawBtn_Click:
        MsgBox Err.Description
        Resume Exit_WstawBtn_Click
        
    End Sub
    Any help will be appreciated..

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Which line is throwing the error?

  3. #3
    lukusm's Avatar
    lukusm is offline Novice
    Windows 7 Access 2007
    Join Date
    Jan 2010
    Location
    Lodz, Poland
    Posts
    9
    The solution is solved..

    Main problem was with references (missing Microsoft DAO library).
    And second one was with returning text boxes values.

    my code was for example 'rekord![name] = nameVar and right code is 'rekord('name').Value = nameVar

    That's good solution.

    But I have one more question:
    I try to make a form to add new person to database. I made radio boxes to have a choice to call different forms (add person, add supporter, add shop etc.). And this works - but when I click on this radio button the form is opened in new window. I'd like to have it on the same form as radio buttons (like in html frame _self). I don't know at all how to do this.

    If I should write vba code that after clicking on radio button chooses form and load it into choosed frame/subform/tab?

  4. #4
    lukusm's Avatar
    lukusm is offline Novice
    Windows 7 Access 2007
    Join Date
    Jan 2010
    Location
    Lodz, Poland
    Posts
    9
    Does anybody know how to resolve this second problem?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 09-30-2009, 09:40 AM
  2. query problem i have a problem wi
    By maxx3 in forum Queries
    Replies: 0
    Last Post: 06-29-2009, 02:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums