Results 1 to 4 of 4

Thread: Update QUERY

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    51

    Update QUERY

    Hello All;
    am new to VBA and Access
    I have a situation where i have two combo boxes (named a , b)
    when the user select an item from combo "a", i want to load some values from a table and load them into combo box 'b"

    how can i insert value of the combo box into the Query? can anyone please provide an example?

    another question, how can i pass a parameter to a report (when opering it) how's the button's calling the report should be coded, and the report, how can it get it?
    FiDz

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Answer to Q#2:
    VB Code:
    1. Application.DoCmd.OpenReport "TestQuestions", acViewPreview, ,"WHERE Something = 'Somethingelse'", acWindowNormal
    Answer to Q#1:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Combo1_Click()
    4.     Call PopulateCBO
    5. End Sub
    6.  
    7. Private Sub Combo1_KeyUp(KeyCode As Integer, Shift As Integer)
    8.     Call PopulateCBO
    9. End Sub
    10.  
    11. Private Function PopulateCBO()
    12.  
    13.     'Using your previously populated recordset from database
    14.     With Combo2
    15.         DoEvents
    16.         .Clear
    17.         Do While RS.EOF = False
    18.             .AddItem RS.Fields("Field1").Value
    19.             RS.MoveNext
    20.         Loop
    21.     End With
    22.    
    23. End Function
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    51
    Thanks,
    As for question 1:
    i need to update the recodSource as follows:
    select OfferID from Offers Where X = THE VALUE OF THE SELECTED COMBO!

    whats the exact statement of it ?
    FiDz

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    To retrieve the selected items?
    Code:
    "SELECT OfferID FROM Offers WHERE X = '" & Combo1.Text & "'"
    To update the selected item with a value from combo 2?
    Code:
    "UPDATE Table1 SET Field1 = '" & Combo2.Text & "' WHERE Field1 = '" & Combo1.Text & "'"
    Not sure how you need them to work, but those are the syntax.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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