473,427 Members | 1,755 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,427 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 4021
NeoPa
32,556 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,556 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,556 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,556 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,556 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.