473,574 Members | 2,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

7 New Member
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:=a cFormsDS, ,WhereCondition "FinCoachin g Enrollment File 2"!.Client__Nam e = " & "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 4028
NeoPa
32,564 Recognized Expert Moderator MVP
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 New Member
THanks, NeoPa.
Can a table and variable appear like this? "FinCoachin g Enrollment File 2"!.Client__Nam e?
Jun 20 '21 #3
NeoPa
32,564 Recognized Expert Moderator MVP
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 New Member
I want to reference a table named "FinCoachin g 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,564 Recognized Expert Moderator MVP
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 Recognized Expert Moderator Specialist
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,564 Recognized Expert Moderator MVP
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 Recognized Expert Moderator Specialist
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,564 Recognized Expert Moderator MVP
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
6987
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 have a Table, in exactly the same Field format, in each of these 'Weekly' DataBases. I want to set-up a new 'Master' Database, so that I can write...
2
2677
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 happened (hourglass for about 2 seconds then nothing). I tried relinking the tables and got the same response. (Access even completely bombed out...
1
1839
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 transaction between client anh server, server will check cerfiticate of client connect to it. How do i do that? Thanks for your reply.
0
1043
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 mouse up events on the client-side. For example, suppose you have a button to control the zoom lens on a camera. When you click down on the...
2
17704
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 from the database but I am not sure how do I put a command button and associate a macro with that using C#. Can anyone help me?? Thanks in...
6
1811
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) and then instantiate a new form. I created a new form form2 and then just on double click on a button.... dim form as new form2 form.show
1
1224
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 full of "projects" for the whole company. I am pulling only the "projects" that apply to my division. this linked database is read only and i have...
3
3209
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 categories in one form the user will scroll it down untill he/she fills up all the information... the alternative solution is i have to cut the form...
0
1355
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 way to create a new style of drop down like this?
0
7805
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8053
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7817
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8098
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6454
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5622
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5301
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3752
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.