Results 1 to 3 of 3
  1. #1
    doneill is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2020
    Posts
    1

    Refreshing a form using the primary key.

    Hello, Ihave spend way too much time trying to refresh a Form that is driven from asingle table. The Form has a few simple Text and Combo dropdown boxes using simple queries to other tables and obviously joining to the maintable. I am trying to add a dropdown /combo to refresh the Form when I select new data. My Combo box is giving me the primary key, TransID, that is also an AutoNumber. With that ID I would like to refresh the form. I have tried various flavors of the belowwith little success. I am new to ACCESS/ VB so keep that in mine.


    Debug.PrintMe.Combo183.Value
    ** 112932


    'Triedvarious combinations of the following....



    strSQL= "SELECT * from services where TransID = " & Me.Combo183.Value
    Debug.Print strSQL
    ** SELECT * from services where TransID =112932

    ' DoCmd.RunSQL strSQL --won't compile
    ' DoCmd.GoToRecord acDataQuery,"strSQL", acNext, 1 -- won't compile

    DoCmd.FindRecord Combo183.Value, , False, ,True, , True ' goes to next Record
    DoCmd.GoToRecord

    Me.Combo183.Requery

    DoCmd.RefreshRecord

    Me.Combo183.SetFocus

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If you're trying to load the form with just that record, your SQL could be used as the form's record source

    Me.RecordSource = strSQL
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Try this in the AfterUpdate event of the combo:
    Code:
    Private Sub Combo183_AfterUpdate()
    On Error Resume Next
    Me.TransID.SetFocus 'assumes you have a visible text box bound to TransID
    DoCmd.FindRecord Me.Combo183
    Me!Combo183.SetFocus
    Me.Combo183= Null
    End Sub
    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Refreshing Form and Subform
    By faythe1215 in forum Forms
    Replies: 6
    Last Post: 04-21-2016, 04:51 PM
  2. Refreshing a form upon opening
    By an1bone in forum Forms
    Replies: 5
    Last Post: 08-07-2015, 06:39 AM
  3. Refreshing a table from the form
    By ddkolb in forum Access
    Replies: 1
    Last Post: 08-08-2014, 12:21 AM
  4. Refreshing the form vs. requerying
    By Access_Novice in forum Forms
    Replies: 9
    Last Post: 01-01-2014, 07:24 PM
  5. Replies: 0
    Last Post: 11-23-2011, 04:06 PM

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