Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59

    entry form

    I am trying to figure out how to create a form that will list all the records from a table.
    When the user selects one of those records, textboxes on the form will populate with that records values allowing the user to modify or add new records.


    How do I do this?

    I have the table
    I have a query that grabs the fields I want in the table to show up in the list.
    I then need a bunch of textboxes that show those fields as well as a couple others that are not in the list but are in the query.

    THanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    You want a list of records (a listbox?) that when one item is clicked will populate a form? One way might be to have the form's RecordSource refer to listbox column with unique ID as filter criteria. Then in AfterUpdate event of listbox refresh the form. But that might prevent adding new records (probably main reason I avoid setting dynamic parameters in queries). Another method is to use VBA to set Filter and FilterOn properties of the form.
    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.

  3. #3
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    Quote Originally Posted by June7 View Post
    You want a list of records (a listbox?) that when one item is clicked will populate a form? One way might be to have the form's RecordSource refer to listbox column with unique ID as filter criteria. Then in AfterUpdate event of listbox refresh the form. But that might prevent adding new records (probably main reason I avoid setting dynamic parameters in queries). Another method is to use VBA to set Filter and FilterOn properties of the form.

    how would the syntax go in teh recordsource to set the form to the selected listbox record?

  4. #4
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    Something like this?

    SELECT tbl_V4_Lessons.ID, tbl_V4_Lessons.LessonID,tbl_V4_Lessons.LessonSubje ct,tbl_V4_Lessons.LessonName,tbl_V4_Lessons.Lesson Description
    FROM tbl_V4_Lessons
    WHERE (((tbl_V4_Lessons.ID)= List1.ID));

  5. #5
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    The above works in the RecordSource but it asks me for the ID when the form opens....

    But How can I adapt this to VBA code and place it in say Change Event of the listbox

    I guess I am askign how to write the VBA to Set the RecordSource of the form after the listbox selected value changes

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    WHERE (((tbl_V4_Lessons.ID)= Forms!List1!ID));

    I would use AfterUpdate event.

    As I said, that might cause issue with adding records. But see what happens.
    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.

  7. #7
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    I tried this in the AfterUpdate of the Listbox
    I get a datatype mismatch error

    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = '" & Me![List16] & "'"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Is the ID field number datatype? If so, don't use apostrophe delmiters. Apostrophe is for text, # for date, nothing for number.
    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.

  9. #9
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    I am confused now....

    Form RecordSource:

    SELECT tbl_V4_Lessons.ID, tbl_V4_Lessons.LessonID,tbl_V4_Lessons.LessonSubje ct,tbl_V4_Lessons.LessonName,tbl_V4_Lessons.Lesson Description
    FROM tbl_V4_Lessons
    WHERE (((tbl_V4_Lessons.ID)= Forms!List1!ID));


    ListBox Query:
    SELECT [qry_V4_AllRecords_NewLessons].[ID], [qry_V4_AllRecords_NewLessons].[LessonID], [qry_V4_AllRecords_NewLessons].[LessonSubject], [qry_V4_AllRecords_NewLessons].[LessonName], [qry_V4_AllRecords_NewLessons].[LessonDescription] FROM [qry_V4_AllRecords_NewLessons]


    What do I do in the Listbox16 After Update?

  10. #10
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    I have to above 2 things and then this in the Listbox After Update event

    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = Me![List16]"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark

    I get an error...cant find List16...Bad Syntax?

  11. #11
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    Think I got it...one second

    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = " & Me![List16] & ""
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark

    NO STRIKE THAT STILL NOT CHANGING the form when I select the record in the listbox...I have 3 bits of code...the 2 in my prior post (one recordsource for the Form, the other RowSource set to a query)...
    Then the 3rd bit above...trrying to do this on the AfterUpdate event on the listbox16

    uggggg

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    No dot between Recordset and Clone. Here's how I use the RecordSetClone:
    Code:
    With Me.RecordsetClone
    .FindFirst "LabNum='" & Me.tbxLABNUM & "'"
    If .NoMatch = False Then
        Me.Bookmark = .Bookmark
    End If
    End With
    The EOF test should work also.
    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.

  13. #13
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    This is all the code I have: I click the listbox and nothing happens....thank you for your help...I know this is not that complicated....just not doing something right....uggg


    Form RecordSource:
    SELECT tbl_V4_Lessons.ID, tbl_V4_Lessons.LessonID,tbl_V4_Lessons.LessonSubje ct,tbl_V4_Lessons.LessonName,tbl_V4_Lessons.Lesson Description
    FROM tbl_V4_Lessons
    WHERE (((tbl_V4_Lessons.ID)= Forms!List1!ID));

    ListBox Query:
    SELECT [qry_V4_AllRecords_NewLessons].[ID], [qry_V4_AllRecords_NewLessons].[LessonID], [qry_V4_AllRecords_NewLessons].[LessonSubject], [qry_V4_AllRecords_NewLessons].[LessonName], [qry_V4_AllRecords_NewLessons].[LessonDescription] FROM [qry_V4_AllRecords_NewLessons]

    AfterUpdate On Listbox16:
    Private Sub List16_AfterUpdate()
    With Me.RecordsetClone
    .FindFirst "ID=" & Me![List16] & ""
    If .NoMatch = False Then
    Me.Bookmark = .Bookmark
    End If
    End With
    End Sub

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Is the listbox name List1 or List16? One of those needs to be fixed.

    I use dot (.) instead of bang (!) whenever possible because it will provoke intellisense popup tips in VBA.
    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.

  15. #15
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    I do this and I can get the ID returned in the message box....Its the Primary Key Autonumber field integer

    But the form value does not change....uggggg

    Its List16....do i need to refresh the main form?

    Dim Test As Integer
    Test = Me.List16.Value
    MsgBox Test

    With Me.RecordsetClone
    .FindFirst "ID= " & Me.[List16] & ""
    If .NoMatch = False Then
    Me.Bookmark = .Bookmark
    MsgBox "Nothing"
    End If
    End With

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. To open a form, sub form if text box entry exist in Query
    By george.vniekerk in forum Programming
    Replies: 2
    Last Post: 08-08-2011, 12:50 AM
  2. Form not allowing new entry
    By Lshy01 in forum Forms
    Replies: 1
    Last Post: 02-04-2011, 10:19 AM
  3. form for New Entry Only
    By bopsgtir in forum Forms
    Replies: 3
    Last Post: 12-30-2010, 09:11 AM
  4. Sub Form Data Entry
    By OldBloke in forum Forms
    Replies: 1
    Last Post: 08-09-2010, 06:58 AM
  5. No entry on open form
    By grant.smalley in forum Forms
    Replies: 4
    Last Post: 01-07-2010, 01:23 AM

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