473,289 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Want to create VBA to create a button which will go to the relevant line in a linked database for a client

7 Nibble
I'm trying to write VBA to create a button which will go to the relevant line in a linked database for a specific client. First I need to have VBA that IDs when the client name in the report matches that in the linked table.

This is what I have so far.
DoCmd.OpenForm "Clients with matches Full Report",View:=acFormsDS, ,WhereCondition "FinCoaching Enrollment File 2"!.Client__Name = " & "Client with matches Full Report"!Client_Name, ,

When it gets to Wherecondition it says it was expecting a parameter.

Thanks.
Jun 18 '21 #1
9 4017
NeoPa
32,554 Expert Mod 16PB
You have the wrong format for the call of DoCmd.OpenForm. Check with the documentation for the correct parameters to use but one thing you certainly cannot do is to mix up positional parameters with named ones. If you want to use named parameters, and I do recommend that where possible, then the format is :
Expand|Select|Wrap|Line Numbers
  1. NameOfParameter:=Value
A WhereCondition parameter must be a string value that is correctly formatted as a SQL WHERE clause.
Jun 18 '21 #2
hwsilver
7 Nibble
THanks, NeoPa.
Can a table and variable appear like this? "FinCoaching Enrollment File 2"!.Client__Name?
Jun 20 '21 #3
NeoPa
32,554 Expert Mod 16PB
Hi there.

No. That wouldn't be correct syntax.

To be fair, I've very little idea what you're asking as you give no context clues, but I can say with certainty that whether your question is about SQL or VBA then the answer is definitely "No". Otherwise, you may want to consider making your comments clearer so they make sense to those of us trying to understand you.
Jun 21 '21 #4
hwsilver
7 Nibble
I want to reference a table named "FinCoaching Enrollment File 2" that contains a variable named Client__Name. One source said to use quotes when a file name has spaces.

What is the correct way to do this in VBA?

Thanks.
Jun 28 '21 #5
NeoPa
32,554 Expert Mod 16PB
VBA doesn't reference Table Fields directly. I say Fields because Tables don't have Variables and I expect that's what you're trying to say.

I was rather hoping you'd do a little bit of work before replying to ensure what you ask makes sense this time, rather than leaving it up to us again to guess what it is you're trying (but not very hard) to express. All I see is a simple repetition of the same question that was so poor before. Nevertheless, for now, I will attempt to answer as well as I can and guess what you mean.

So then, VBA is an Access (Office+) language that works with many entities in many different ways. It doesn't give access to data (Tables, Queries, Fields, etc) natively. As such your question doesn't make sense as it stands.

You can access data within Tables by Field (Bearing in mind obviously you also need to ensure you have the correct record selected.) either by using DLookup() or by using Recordset coding in your VBA.

Generally speaking, and this is more for SQL than VBA though they can overlap here a bit, when dealing with items whose names contain spaces and/or other characters that may otherwise be treated as delimiters you should enclose them in brackets []. Thus, when referencing the table you would use [FinCoaching Enrollment File 2].

It is generally considered wiser not to use such characters in names but we don't always control what we have to work with so it helps to know how to handle them when forced to.
HWSilver:
One source said to use quotes when a file name has spaces.
That may be true, but I doubt they were talking about what you're asking about. I know of no situation where quotes, of either type (' or ") would be of any help in this regard at all.
Jun 29 '21 #6
twinnyfo
3,653 Expert Mod 2GB
I would do this:

Expand|Select|Wrap|Line Numbers
  1. Dim strWhere As String
  2.  
  3. strWhere = "[FinCoaching Enrollment File 2].Client_Name = " & Me.Client_Name
  4.  
  5. Call DoCmd.OpenForm( _
  6.     FormName:="Clients with matches Full Report", _
  7.     View:=acFormsDS, _
  8.     WhereCondition:=strWhere)
This assumes Client_Name (with only one underscore) is a Field in the referenced Table and a field available in the Form/Report from which you are calling this code.

Hope that hepps!
Jun 29 '21 #7
NeoPa
32,554 Expert Mod 16PB
Tsk tsk Twinny. I hope you aren't assuming that Me.Client_Name takes numeric data :-(

PS. No sneakily fixing it before claiming innocence!
Jun 29 '21 #8
twinnyfo
3,653 Expert Mod 2GB
True, true, NeoPa! Faulty assumption on my part, but hopefully the suggestion points OP in the right direction.

I should have learned my lessons by now—I’m just so accustomed to numerical values. Here’s the text version:

Expand|Select|Wrap|Line Numbers
  1. Dim strWhere As String
  2.  
  3. strWhere = "[FinCoaching Enrollment File 2].Client_Name = '" & Me.Client_Name & "'"
  4.  
  5. Call DoCmd.OpenForm( _
  6.     FormName:="Clients with matches Full Report", _
  7.     View:=acFormsDS, _
  8.     WhereCondition:=strWhere)
Still don’t know fer sher if this is what OP is looking for.

Thanks for the hepp!
Jun 30 '21 #9
NeoPa
32,554 Expert Mod 16PB
True. It's hard to answer when people can't even ask the question properly. I guess throwing out examples might help in case one of them hits what they're actually looking for. They certainly don't hurt ;-)
Jun 30 '21 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: G rumpy O ld D uffer | last post by:
This is probably a 'Low-Level' question to all the ACCESS experts but I've only been using ACCESS for a couple of weeks. I've been given 30+ (and counting) separate 'Weekly' Databases which all...
2
by: Robert McGregor | last post by:
Hi all, I've got a Front End / Back End database that was working just fine. One day i opened the FE to find that if I tried to open one of the linked tables from the database window, nothing...
1
by: luciano | last post by:
Hi everyone, I want to create a application and a webservice, application connect to web service to activate, web sevice will create a certificate to authenticate this client, for each...
0
by: RickL | last post by:
Hi, I'm fairly new to web application development and I'm creating an application for camera control, which leads to the question. I want to create a button that can respond to mouse down and...
2
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report...
6
by: Savante | last post by:
I have been writing a datalogging application. It reads in double's into a database. I want to be able to click on a row in a database (holds name of variable and also current value of variable)...
1
Stang02GT
by: Stang02GT | last post by:
This is a little difficult to explain so bear with me, and if anyone has any questions i will be happy to clarify for you I have a database linked into my access database. This linked database is...
3
vyon13
by: vyon13 | last post by:
hello... i have a problem regarding to my proj that i was working... this is the prob.. in my application form there are so many categories to be fill up... i realize that if i will put all the...
0
by: emadadel2008 | last post by:
I want to create a new DropDown menu with different conditions like: Contains, NotContains, NotEqual, etc... So I can select this type of drop down for other columns. Janus Gridex1 Is there a...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.