Results 1 to 5 of 5
  1. #1
    darekg11 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2012
    Posts
    7

    Dynamic forms - new records don't automatically to form

    Hi, I have following problem:



    I have a form where by entering value(ID of product) and pressing ENTER rest of field (price, description) is loaded automatically. For doing so I added this code to On Key Pressed event:

    Code:
    Private Sub pole_numer_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
    Dim test As Double
    Dim ada As Integer
    Dim check As Integer
    Dim bla As Integer
    check = -1
    Dim rekordy As DAO.Recordset
    test = Val(pole_numer.Text)
    Set rekordy = CurrentDb.OpenRecordset("Produkty") //PRodukty = table
    Do While Not rekordy.EOF
    If rekordy!id_produktu = test Then
    nazwa.Value = rekordy!nazwa
    cena.Value = rekordy!cena
    check = 0
    ilosc.SetFocus
    Exit Do
    End If
    rekordy.MoveNext
    Loop
    Set rekordy = Nothing
    End If
    If check = -1 Then
    bla = MsgBox("Nie znaleziono", vbDefaultButton1, "Error") //Not found product
    nazwa.Value = ""
    cena.Value = ""
    ilosc.Value = ""
    End If
    End Sub
    It is working great but I want to be able to select more records but forms don't add new field to itself.

    It is hard for me to explain. But basicly I want to enter one product and then I want form to create new fields so I can enter another product again.

    I will upload 2 databases for You to show what I want to achieve.

    First database: http://www.sendspace.com/file/ttn690 (Sorry for Polish names etc)

    On form Zamówienia You have a "Szczegół" button, by clicking it You enter: "Szczegoly zamowienia" form where You can see what I want to do.

    Second database: http://www.sendspace.com/file/ho83iz

    On form Zamowienia_pod1 You have a form which doesn't work the way I want.


    I will appreciate any kind of help here.

    Thanks.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If you were to use a Continuous Form View, then I believe you will get the results for which you are looking. Even Datasheet View would do it.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Why are you building form name using ChrW()? Is it because of Polish characters? Try:
    strDocName = "FormularzSzczeg" & ChrW(243) & ChrW(322) & "y"
    However, ChrW(322) looks like a normal English 'l'

    When opening Zamówienia or running any button click events I get error message 'The expression On Click you entered as the event property setting produced the following error: A problem occurred while Hurtownia was communicating with the OLE server or ActiveX Control. ...'

    Also, I find code in FormularzZamówienia is:
    Code:
    Sub ŁączePrzełącznika_Click()
    On Error GoTo ŁączePrzełącznika_Click_Err    If ChildFormIsOpen() Then
            CloseChildForm
        Else
            OpenChildForm
            FilterChildForm
        End If
    ŁączePrzełącznika_Click_Exit:
        Exit Sub
    ŁączePrzełącznika_Click_Err:
        MsgBox Error$
        Resume ŁączePrzełącznika_Click_Exit
    End Sub
    Does this work?

    RuralGuy's comment helped me understand your issue. What you need to do is move to a new record. Make sure form AllowAdditions property is set to Yes (your form is set for this), regardless if form is Single, Continuous, or Datasheet. Can use the Access intrinsic record navigation toolbar at bottom of form to move to new record or use a custom command button with code (macro or VBA).
    Last edited by June7; 09-09-2012 at 07:47 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    darekg11 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2012
    Posts
    7
    I still can't get it to work, damn.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    What did you try? What happens - error message, wrong results, nothing?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Dynamic Form, Dynamic labels/ captions?
    By JFo in forum Programming
    Replies: 15
    Last Post: 10-12-2011, 08:33 PM
  2. Dynamic (VBA-Created) Forms in accde?
    By phi11yguy19 in forum Programming
    Replies: 0
    Last Post: 07-02-2011, 09:56 PM
  3. Replies: 3
    Last Post: 03-28-2011, 11:49 AM
  4. Multiple dynamic forms.
    By ser01 in forum Forms
    Replies: 1
    Last Post: 02-22-2010, 11:44 AM
  5. linking forms by ID - automatically add ID
    By jlcaviglia-harris in forum Forms
    Replies: 0
    Last Post: 04-17-2009, 03:51 PM

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