I have a query with fields defined from a table. I have a label on a form that I would like to add to this query, the forms name is params and the label name is match4. The labels caption can be changed on the form and I want that new caption to be in the query, can this be done. Any help would be appreciated.
Thanks again for your help.
Sep 12 '12
11 5606
Ok, I changed those labels to textboxs and change the querydefs to .[value] but I get the same thing. I think maybe I need to come up with some other way to get this done.
Thanks for all your help.
zmbd 5,501
Recognized Expert Moderator Expert
CD Tom,
Don't give up just yet.
Let's look at the two textboxes Params.Club_nam e, Params.Regional Name for ease let's call them txtClubname and txtRegionalName .
When the user enters the information into these two boxes so that [textclubname]=userclubname and [txtRegionalName]=userregionalna me let's determine what you want to do...
Somewhere we have to have a table to work with...
Now this table either has to have fields in it named "userclubna me" and "userregionalna me" or you're trying to gather records where the information in the table field meets that requirement.
Case one:
tbl_example1
[PK] autonumber - primary key
[userclubname] - text(50) required, no duplicate
[userregionalnam e] - text(50) required, no duplicate - 'This code is written from memory, it has not
-
'been checked for typos against the complier
-
'sorry, not at a PC with Access or VB installed
-
'
-
Dim zdb As DAO.Database, zqrydef As DAO.QueryDef
-
Dim zsql as string
-
Dim zuserinput1 AS string, zuserinput2 AS string
-
'
-
'setup for the database
-
Set zdb = CurrentDB
-
'
-
'check to see if the query exsists
-
'qry_example
-
'and if so then remove it from the collection
-
For each zqrydef in zdb.querydefs
-
'
-
if lcase(zqrydef.name)="qry_example" then
-
zqrydef.delete "qry_example"
-
end if
-
next zqrydef
-
'
-
'now build the query for the selected fields:
-
zuserinput1 = me.txtclubname.value
-
'example user entered userclubname
-
'
-
zuserinput2 = me.txtregionalname.value
-
'example user entered userregionalname
-
'
-
'very simple select query, no wheres no whys
-
'just get the two fields from the table and
-
'show all records within the table tbl_example1
-
'
-
'NOTE the space appended in string!
-
zsql = "Select " & zuserinput1 & "," & _
-
"zuserinput2 & " " & _
-
"FROM tbl_example1;"
-
'
-
'Using our example this string should evaluate to:
-
'Select userclubname,
-
' userregionalname
-
'From tbl_example1;
-
-
'create the query (see why we searched first?)
-
'if you try to create a query with the same name
-
'access will have a tempertantrum
-
'
-
Set zqrydef = zdb.CreateQueryDef("qry_example", zsql)
-
'
-
'That's it... you can add code to open the query
-
'the user can open the query from the navigation pane
-
'you can use the query in the transfersheet method, etc..
-
'
-
'Clean UP - - Always a cleanup step
-
zdb.close
-
set zdb = nothing
-
set zqrydef = nothing
-
end sub
Case two:
tbl_example2
[PK] autonumber - primary key
[clubnames] - text(50) required, no duplicate
[regionalnames] - text(50) required, no duplicate
We're going to repeat some of the above code: - 'This code is written from memory, it has not
-
'been checked for typos against the complier
-
'sorry, not at a PC with Access or VB installed
-
'
-
Dim zdb As DAO.Database,
-
Dim zrs As DAO.recordset '<<<notice
-
Dim zsql as string
-
Dim zuserinput1 AS string, zuserinput2 AS string
-
'
-
'setup for the database
-
Set zdb = CurrentDB
-
'
-
'now build the query for the selected fields:
-
zuserinput1 = me.txtclubname.value
-
'example user entered userclubname
-
'
-
zuserinput2 = me.txtregionalname.value
-
'example user entered userregionalname
-
'
-
'very simple select query, no wheres no whys
-
'just get the two fields from the table and
-
'show all records within the table tbl_example2
-
'
-
'NOTE the space appended in string!
-
zsql = "Select * " & zuserinput1 & "," & _
-
"FROM tbl_example2 " & _
-
"WHERE(([clubnames] = '" & zuserinput1 & "')" & _
-
"AND ([regionalnames] = '" & zuserinput2 & "'));"
-
'Using our example this string should evaluate to:
-
'Select *
-
'From tbl_example2
-
'WHERE (([clubnames] = 'userclubname') AND
-
'(regionalnames] = 'userregionalname'));
-
'
-
'Now lets open a record set based on the sql string:
-
set zrs = zbd.openrecordset(zsql,dbOpenDynaset)
-
'
-
'That's it... you can add code to pull information out
-
'of the record set for display on the forms or whatever
-
'you desire (well... almost)
-
'
-
'Clean UP - - Always a cleanup step
-
zdb.close
-
set zdb = nothing
-
set zrs = nothing
-
end sub
As I said, I pulled all of the code for the two blocks out of my head... amazing how lazy I've gotten with the vba editor window... so there might be a syntax error.
-
z
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Joshua Russell |
last post by:
Hi,
Both the methods below open up a windows form called MasterForm. However, one works better than the other. Method 1 opens the form correctly but I don't have any reference to the instance of master form. Method 2 opens the form but when I right click on the Notify Icon I don't get the context menu that I should be seeing. I can interact with the main form window but I cannot interact with the NotifyIcon. Method 2 gives a object reference...
|
by: Adonai |
last post by:
Hi, I'm having an issue with this code that I'm writing, I'm curious as
to why the windows form label (lblTime) isn't getting updated with the
new variable when I use the timer. I made a blank form with only the
timer and the label, and it works fine, is there something else I need
to do with the threads to get this to work? I'm a bit lost here.
Thanks in advance -- Aaryn
// Code Start
|
by: jhs |
last post by:
Hello,
I developping a .NET windows form application an need some help to create an
array of System.Windows.Forms.Label in order to be able to manage all of
them using index.
I'm trying to do this in form_load void:
System.Windows.Forms.Label labelArray = new
System.Windows.Forms.Label;
for (i=1;i<91;i++)
|
by: Mike Bulava |
last post by:
I have created a base form that I plan to use throughout my application let
call the form form1. I have Built the project then add another form that
inherits from form1, I add a few panel controls each with a couple of
controls in them I then rebuilt my project and my new panels and all
controls they contained are gone... I've looked through the Auto generated
code but don't see anything that looks wrong Any body have any idea why
this...
|
by: jcrouse |
last post by:
Is there a quick and easy way to change the color of a label controls border
from the default black to white?
Thank you,
John
| |
by: Neil Wallace |
last post by:
Hi,
This is an odd one. I've been struggling to get "double click" to work well
for my controls.
The same event handler works perfectly for buttons, but not for labels.
Can anyone tell me why not?
Below is an working VB.Net example to illustrate what I mean.
|
by: Geraldine Hobley |
last post by:
Hello,
In my project I am inheriting several forms. However when I
inherit from a form and add additional subroutines and methods to my
inherited form I get all sorts of problems. e.g. I sometimes get
MyVarialble is not declared errors when the variable is quite clearly
declared, when I change it to public and then back again to private the error
goes away!!!
Also I get lots of member not found errors, these however don't stop me from...
|
by: deekay |
last post by:
Im trying to update a database where our users have been
entering/editing all data using queries to now use forms instead. The
first step that I want to take is to convert the queries to forms in
datasheet view so that they look exactly the same. I just want to know
whether it is better to bind the forms record source to the queries or
to a sql statement that would include the relevant tables and fields.
Please advise
thanks
|
by: nave11 |
last post by:
How to add Context menu to a class derived from System.Windows.Forms.Label ?
This label will be dragged on a designer surface on runtime.
For example, to add a context menu with "Copy" and "Paste"
to a Label or TextBox?
I have tried adding the context menu code in designer , and i can get the context menu at design time , but cannot see that at runtime.
if any other way its possible , please let me know.
|
by: Peter Larsen [] |
last post by:
Hi,
I have two questions related to the Label control.
How do i prevent the label from expand the canvas into 2 lines (word wrap)
??
At the moment i set AutoSize to false (to prevent the word wrap from
happening) and Anchor to Left, Right (to enable the with autosize).
How do i prevent a tool-tip from happening if the text is to large to fit in
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |