PDA

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



cyburner
02-24-2021, 06:52 PM
Moderator Notice:
Copied by me from here
Re https://excelfox.com/forum/showthread.php/2723-Using-text-in-an-excel-cell-drop-down-list-to-open-Microsoft-access-to-a-specific-record-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