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.
11 5592 zmbd 5,501
Recognized Expert Moderator Expert
If you are talking about a query that you have built from the ribbon/menu then the only way is to use the qrydef collection.
Delete the old query and then rebuild and add it to the collection.
If you are talking about an sql string that is built in VBA and then used to open a record set, then just use the field caption in your code to build the string.
-z
Thanks for the reply. I'm not sure how to add a label from a form to a query. I use the simple query design not the wizard when I usually design a query, although I do also use the sql string to build query's when things in the query need to change. I not sure how to code a form label in the sql string or when I just use the query design.
zmbd 5,501
Recognized Expert Moderator Expert
OK
In order not to go into the deep end we're going to have to understand what it is you're doing. Although it is not unusual to change a label caption (I use them for user feed back) it is unusual to use the control as I suspect you are doing; thus, please provide some detail as to what you're doing with the form and some example code with an explanation of any errors. (when you post code, select it with the mouse and click the <code/> button above next to the undo/redo.
-z
Boy, let's see if I can explain this further. I really don't have any code to show you as the only thing the query does is export the data to a .txt file. But here's what I'm trying to accomplish. The Params form is used to set all the options for the program. In the params form the user can setup 5 events, this is where the label caption comes in, they can change the names of the events, this give the user a little more flexibility so instead of just a standard name they can name the event what ever they wish. The user then can export the data to the .txt file where a hand held computer will import that data. The data for the hand held computer comes from the single table but I want to have the event name also show up with that data. I probably could add some columns to the table and store the data in there but I would like to just and the caption fields to the query.
I hope this makes sense if not let me know and I'll try again.
Rabbit 12,516
Recognized Expert Moderator MVP
I don't understand either why you would want to include the label caption as a field in a query. Label captions don't change and are static unless you're using code/macros to change the caption value.
But if you use this in a query def, it will pull the label caption into the query. - SELECT PK, [Forms]![FormName]![LabelName].[Caption] AS LabelCaption
-
FROM someTable
With that, if my label caption is Name: and I have 3 records in the table, my results would be: zmbd 5,501
Recognized Expert Moderator Expert
I think what we have here is a failure to communicate
:) (chuckle)
Take a look at the following picture.
I believe that you are referring to textbox controls and not labels as labels are not normally something a user can modify in form view. So all of the "unbound" entries are controls for user interaction.
If we're talking about textbox controls then you have basically the same thing as Rabbit's just for values: - SELECT PK,
-
[Forms]![FormName]![TextBoxName].[Value]
-
AS TextBoxValue
-
FROM someTable
-z
I understand the difference between the Textbox and the Label and I do use the Label. I know this is probably not the correct way to do this but because this is a new option in the program to extract this data out to a .txt file I'm trying to make it so I don't have to make big changes to the program. I tried the do the querydef but it doesn't work here's the code to build the query - (A cut and paste may not work on this )
-
Set ExtractParm = db.QueryDefs("Extractparm")
-
ExtractParm.SQL =
-
"SELECT [forms]![Params]![Match4].[Caption]
-
as EventName,
-
Params.Club_name, Params.RegionalName,
-
Params.WildbunchStages, Params.Wildbunchdate,
-
Params.RankPointsWB, Params.TotalTimeWB,
-
Params.RankbyClassWB, Params.WBShotPoint,
-
Params.MisseTime, Params.PenaltiesTime,
-
Params.BonusstageWB1, Params.BonusstageWB2," & _
-
"Params.BonusstageWB3, Params.BonusstageWB4,
-
Params.BonusstageWB5, Params.BonusstageWB6,
-
Params.BonusstageWB7, Params.BonusstageWB8,
-
Params.BonusstageWB9, Params.BonusstageWB10,
-
Params.BonusstageWB11, Params.BonusstageWB12," & _
-
"Params.MatchDQTotal, Params.StageDQTotal,
-
Params.DNFTotal, Params.StageDQTargets,
-
Params.TargetPlus
-
FROM Params"
When I run the query it ask for a value to enter in the forms field.
zmbd 5,501
Recognized Expert Moderator Expert
CD Tom,
Hopefully you got the tag line... it's a play on Cool Hand Luke and the chuckle
I really was hoping that you ment text boxes and not labels. This would have been a very straight forward way of building a query.
By using labels for a job that text boxes are designed to do, you make your coding that much more difficult and the enduser will truely dislike haveing a dozen prompts showup (and I'm guessing here...) You won't beable to intercept the responses to build the query as you want because the engine is trying to get the values to compare against data... not values to build fields.
By using the textboxes, your user opens the form, enters the text in the boxes, and the vba builds the query for them when what ever command button is pressed. You can take the values and use them in a "where" clause or use them to build the query structure.
The effort (IMHO) to try and do what I think you are attempting will be somewhat the same, actually I think more difficult, as redoing what you've already done.
-z
I guess I'll try and change those labels to textboxs and give that a try. Thanks for you advice and help.
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |