Results 1 to 3 of 3

Thread: Using text in an excel cell drop down list to open Microsoft access to a specific record using VB.

  1. #1
    Junior Member
    Join Date
    Feb 2021
    Posts
    3
    Rep Power
    0

    Using text in an excel cell drop down list to open Microsoft access to a specific record using VB.

    Moderator Notice:
    Copied by me to here
    Re https://excelfox.com/forum/showthrea...ecord-using-VB
    Alan








    Hello,
    I'm trying to get a daily menu spreadsheet synergizing with a recipe card database in MS access. (office 16)

    The issue:
    I have a dropdown menu in a cell in Excel. That dropdown list in Excel is generated from a table pulled in from a MS Access database "Recipe" table so I can click and change the daily menu item. When I click that dropdown cell with the current chosen context eg:"Alphabet Chilli" I want VB to use the text in that cell, to open the recipe card I've selected in MS Access form view. I'm trying to capture the text in that cell ("b8") ( also defined it as name "MondayMenu") as the filter criteria for MS Access using this line of code:

    oApp.DoCmd.OpenForm "Recipes", , , "RecipeName=" & Range("b8")

    That action generates this error:


    Microsoft Visual Basic

    Run-time error '3075':

    Syntax error (missing operator) in query expression
    'RecipieName=Alphabet Chilli',

    If I use this line of code and manually tell it the text I want to query using:

    oApp.DoCmd.OpenForm "Recipes", , , "RecipeName='Alphabet Chilli'"

    Everything works. The issue seems to be related to how it's parsing the ' characters, or lack there of.

    Suggestions? Please be kind , I'm new to this. XD
    Last edited by DocAElstein; 03-01-2021 at 12:22 PM. Reason: Copied to Access sub Forum

  2. #2
    Junior Member
    Join Date
    Feb 2021
    Posts
    3
    Rep Power
    0
    I figured out the syntax error. The correct format of the line of code should read:

    oApp.DoCmd.OpenForm "Recipes", , , "RecipeName='" & Range("b8") & "'"

    The quotations and apostrophes weren't quite right.

    Thank you!

  3. #3
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10
    Thanks for lettings us know and sharing your answer.
    I don't know anything about Access, but getting the quotations and apostrophes right in VBA coding generally is something I frequently spend a lot of my life doing, unfortunately ....
    Alan
    A Folk, A Forum, A Fuhrer ….

Similar Threads

  1. Replies: 5
    Last Post: 09-06-2020, 01:51 PM
  2. Replies: 0
    Last Post: 10-24-2017, 09:39 PM
  3. Drop-down list (with filtering)
    By mahmoud-lee in forum Excel Help
    Replies: 2
    Last Post: 02-22-2014, 12:14 AM
  4. Replies: 4
    Last Post: 07-27-2013, 01:34 PM
  5. Replies: 2
    Last Post: 07-23-2013, 06:54 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
  •