Hi,
I am trying to solve a problem since more than 8days, without any real progresses and I am once again begging for help from you guys.
I am trying to attempted a Form automatization, ie a user chooses a CostCenter from a dropbox and then automatically a field OrgUnit and Region should be filled with the corresponding "value". (Table Structure: the main Form is Work with a Table Work, but CostCenter there's also a CostCenter Table with OrgUnit and Region)
I think, the best way to do that is in VB, but if there's a better one, I would certainly give it a shot. So far I have this: -
Private Sub CostCenter_AfterUpdate()
-
-
Dim WCostCenter As String
-
Dim WSQL As String
-
-
WCostCenter = CostCenter
-
-
WSQL = "select CostCenter.* from CostCenter "
-
WSQL = WSQL & "where ((CostCenter.OrgUnit = CostCenter.CostCenterID) LIKE '*" & WCostCenter & "*')"
-
-
OrgUnit.ControlSource = WSQL
-
-
End Sub
-
-
It should work, but it doesn't :-) I am getting the #Name? in the OrgUnit Field. So, I am thinking the problem lies in the select statement, but I don't see it.
Do you?
Thanks a lot
24 2096
Hi,
I am trying to solve a problem since more than 8days, without any real progresses and I am once again begging for help from you guys.
I am trying to attempted a Form automatization, ie a user chooses a CostCenter from a dropbox and then automatically a field OrgUnit and Region should be filled with the corresponding "value". (Table Structure: the main Form is Work with a Table Work, but CostCenter there's also a CostCenter Table with OrgUnit and Region)
I think, the best way to do that is in VB, but if there's a better one, I would certainly give it a shot. So far I have this: -
Private Sub CostCenter_AfterUpdate()
-
-
Dim WCostCenter As String
-
Dim WSQL As String
-
-
WCostCenter = CostCenter
-
-
WSQL = "select CostCenter.* from CostCenter "
-
WSQL = WSQL & "where ((CostCenter.OrgUnit = CostCenter.CostCenterID) LIKE '*" & WCostCenter & "*')"
-
-
OrgUnit.ControlSource = WSQL
-
-
End Sub
-
-
It should work, but it doesn't :-) I am getting the #Name? in the OrgUnit Field. So, I am thinking the problem lies in the select statement, but I don't see it.
Do you?
Thanks a lot
Try it like this and see if it helps: -
Private Sub CostCenter_AfterUpdate()
-
-
Dim WCostCenter As String
-
Dim WSQL As String
-
-
WCostCenter = CostCenter
-
-
WSQL = "select CostCenter.* from CostCenter "
-
WSQL = WSQL & "where (CostCenter.OrgUnit = CostCenter.CostCenterID LIKE ‘“ & Chr(34) & * & Chr(34) & WcostCenter.Value & Chr(34) & * & Chr(34) & “')"
-
-
OrgUnit.ControlSource = WSQL
-
-
End Sub
-
-
WSQL = "select CostCenter.* from CostCenter "
-
WSQL = WSQL & "where (CostCenter.OrgUnit = CostCenter.CostCenterID LIKE ‘“ & Chr(34) & * & Chr(34) & WcostCenter.Value & Chr(34) & * & Chr(34) & “')"
-
-
OrgUnit.ControlSource = WSQL
-
-
End Sub
Thanks for the input, but I don't really understand what you have changed. WCostCenter.Value, what should that be? I define WCostCenter, but whats the value?? And also, what is Chr(34).
Sorry for the questions, but I would like to understand...:-)
-
-
WSQL = "select CostCenter.* from CostCenter "
-
WSQL = WSQL & "where (CostCenter.OrgUnit = CostCenter.CostCenterID LIKE ‘“ & Chr(34) & * & Chr(34) & WcostCenter.Value & Chr(34) & * & Chr(34) & “')"
-
-
OrgUnit.ControlSource = WSQL
-
-
End Sub
Thanks for the input, but I don't really understand what you have changed. WCostCenter.Value, what should that be? I define WCostCenter, but whats the value?? And also, what is Chr(34).
Sorry for the answer, but I would like to understand...:-)
.Value is a typo I forgot to take out. What I have changed are the placement of the quotes and the way the wildcard syntax is presented. Chr(34) is Ascii for the double quote, which is used as a delimiter for the wildcard in a string.
Did you try it (after removing .value)? Any different results??
.Value is a typo I forgot to take out. What I have changed are the placement of the quotes and the way the wildcard syntax is presented. Chr(34) is Ascii for the double quote, which is used as a delimiter for the wildcard in a string.
Did you try it (after removing .value)? Any different results??
Ahhh...ok, thanks for the explanation. Unfortunately, it didn't work.
Ahhh...ok, thanks for the explanation. Unfortunately, it didn't work.
Neither control can have ControlSource set to SELECT query. Did you mean RowSource?
Neither control can have ControlSource set to SELECT query. Did you mean RowSource?
I have to admit, I do not know. I was thinking that ControlSource needs a task to perform, so I assigned ControlSource. However, I have just tried with RowSource, which isn't a usable "control function". Or what do you mean with RowSource?
Ahhh...ok, thanks for the explanation. Unfortunately, it didn't work.
Please provide details as to what "didn't work" means. Errors? what object is highlighted? Place a code break on the line where you are setting the control source = sql....display the sql string in the immediate window, etc. Remember that I don't have the application in front of me....so I am dependent on you for info.
Please provide details as to what "didn't work" means. Errors? what object is highlighted? Place a code break on the line where you are setting the control source = sql....display the sql string in the immediate window, etc. Remember that I don't have the application in front of me....so I am dependent on you for info.
Sorry, with it didn't work I mean: the Field on the Form still gives me the Error: #Name?
Compiling in VB-Editor is fine, no errors.
I appologize and thanks again
I have to admit, I do not know. I was thinking that ControlSource needs a task to perform, so I assigned ControlSource. However, I have just tried with RowSource, which isn't a usable "control function". Or what do you mean with RowSource?
ControlSource property is exactly what you see in form design -> field properties -> Control Source. It by its very nature never could be SQL expression.
You have OrgUnit and Region form controls (let them be "controls", bkz "fields" is generally referred to table/query fields). What are there types? I've asked you about RowSource property bkz just thought they are combos.
ControlSource property is exactly what you see in form design -> field properties -> Control Source. It by its very nature never could be SQL expression.
You have OrgUnit and Region form controls (let them be "controls", bkz "fields" is generally referred to table/query fields). What are there types? I've asked you about RowSource property bkz just thought they are combos.
Thanks for the explanation. So, when I do that (OrgUnit as Controls under properties) and simply write OrgUnit = WSQL in my VB script, I receive runtime error.
CostCenter, OrgUnit and Region are all Text types. CostCenter is the only one with a dropdown list.
Thanks for the explanation. So, when I do that (OrgUnit as Controls under properties) and simply write OrgUnit = WSQL in my VB script, I receive runtime error.
CostCenter, OrgUnit and Region are all Text types. CostCenter is the only one with a dropdown list.
Is your form bound to Table/Query? If so plz post the string in the form RecordSource property, if it is table name plz post list of table fields (names, types) as well.
One more question. Do you expect your query will always return NMT 1 record? If no how do you want to represent multiple records?
Fish,
I am sorry but I have to disagree with you on the Control Source. See this link: http://office.microsoft.com/en-us/ac...327251033.aspx
PDB, I apologise, but nothing about ControlSource could be set to SQL expression. And, according to common sence, how TextBox is supposed to represent result of SELECT query?
PDB, I apologise, but nothing about ControlSource could be set to SQL expression. And, according to common sence, how TextBox is supposed to represent result of SELECT query?
Even if the select statement is limited so that it returns only one value at a time?
Even if the select statement is limited so that it returns only one value at a time?
Have you tried this? I've never.
Anyway OP tries to retrieve all fields, I guess he has more than one.
P.S. I've tried to enter SELECT with aggregate function to ControlSource property. The miracle didn't happen as it had been supposed to be.
Have you tried this? I've never.
Anyway OP tries to retrieve all fields, I guess he has more than one.
P.S. I've tried to enter SELECT with aggregate function to ControlSource property. The miracle didn't happen as it had been supposed to be.
Fish,
I don't think an aggregate function is a good example...but I don't want to spend any more time on this issue. You are right that, in this case, more that one field is being returned to the textbox.
To the OP
--------------
It would be helpful if you could present one row of data to make it easier for us to see exactly what you are trying to accomplish with your sql statement. Maybe you are trying to change the recordSource of the form?
Fish,
I don't think an aggregate function is a good example...but I don't want to spend any more time on this issue. You are right that, in this case, more that one field is being returned to the textbox.
To the OP
--------------
It would be helpful if you could present one row of data to make it easier for us to see exactly what you are trying to accomplish with your sql statement. Maybe you are trying to change the recordSource of the form?
Hi Fish and Hi PDB
You guys had a good discussion and I was very interested to read it. I have to learn a lot. :-)
To my Problem: I have a table structure like that: -
Work (tbl) CostCenter(tbl)
-
...
-
CostCenter ----------------------> CostCenter (Text)
-
.... OrgUnit (Text)
-
Region (Text)
-
Values look like: 008080112 , PWM IT - NPP, NY
The Idea is now: That the User on the FORM, chooses from a DropDown Box a CostCenter, and automatically OrgUnit and Region are filled.
I hope its more clear now.
Thanks
Hi Fish and Hi PDB
You guys had a good discussion and I was very interested to read it. I have to learn a lot. :-)
To my Problem: I have a table structure like that: -
Work (tbl) CostCenter(tbl)
-
...
-
CostCenter ----------------------> CostCenter (Text)
-
.... OrgUnit (Text)
-
Region (Text)
-
Values look like: 008080112 , PWM IT - NPP, NY
The Idea is now: That the User on the FORM, chooses from a DropDown Box a CostCenter, and automatically OrgUnit and Region are filled.
I hope its more clear now.
Thanks
Ok. I would suggest you to try the following. - set Form RecordSource property
- SELECT Work.*, CostCenter.OrgUnit, CostCenter.Region
-
FROM CostCenter RIGHT JOIN Work ON CostCenter.CostCenter = Work.CostCenter;
- set form controls ControlSource properties to correspondent fields
- lock controls correspondent to OrgUnit and Region fields, via setting Lock property to Yes
It works fine in one of my db.
Ok. I would suggest you to try the following.- set Form RecordSource property
- SELECT Work.*, CostCenter.OrgUnit, CostCenter.Region
-
FROM CostCenter RIGHT JOIN Work ON CostCenter.CostCenter = Work.CostCenter;
- set form controls ControlSource properties to correspondent fields
- lock controls correspondent to OrgUnit and Region fields, via setting Lock property to Yes
It works fine in one of my db.
Thanks Fish,
So how did you do that. I am trying it as follows:
1. Set RecordSource to Work
2. CostCenter Properties I create the Event AfterUpdate as follows: -
Private Sub CostCenter_AfterUpdate()
-
-
Dim WCostCenter As String
-
Dim WSQL As String
-
-
WCostCenter = CostCenter
-
-
WSQL = "SELECT Work.*, CostCenter.OrgUnit, CostCenter.Region FROM CostCenter RIGHT JOIN Work ON CostCenter.CostCenter = Work.CostCenter;"
-
-
End Sub
-
3. I fix the Fields under Properties OrgUnit and Region with Control Source OrgUnit and Region (for each field). Additionally, I set the to Locked-YES
That's the right procedure, right? However I am still getting the #Name? Error.
I have just tried another way. Set RecordSource of the field with the SELECT statement and I removed the AfterUpdate Event for CostCenter
When I do that, I can't choose CostCenter anymore. No error message just "ping-sound"
Thanks Fish,
So how did you do that. I am trying it as follows:
1. Set RecordSource to Work
2. CostCenter Properties I create the Event AfterUpdate as follows: -
Private Sub CostCenter_AfterUpdate()
-
-
Dim WCostCenter As String
-
Dim WSQL As String
-
-
WCostCenter = CostCenter
-
-
WSQL = "SELECT Work.*, CostCenter.OrgUnit, CostCenter.Region FROM CostCenter RIGHT JOIN Work ON CostCenter.CostCenter = Work.CostCenter;"
-
-
End Sub
-
3. I fix the Fields under Properties OrgUnit and Region with Control Source OrgUnit and Region (for each field). Additionally, I set the to Locked-YES
That's the right procedure, right? However I am still getting the #Name? Error.
I have just tried another way. Set RecordSource of the field with the SELECT statement and I removed the AfterUpdate Event for CostCenter
When I do that, I can't choose CostCenter anymore. No error message just "ping-sound"
Ok. Once more. - get rid of the CostCenter_AfterUpdate sub
Make the following settings in form design view - set Form RecordSource property
- SELECT Work.*, CostCenter.OrgUnit, CostCenter.Region (form properties)
-
FROM CostCenter RIGHT JOIN Work ON CostCenter.CostCenter = Work.CostCenter;
- set form controls ControlSource properties to correspondent fields (each control properties)
- lock controls correspondent to OrgUnit and Region fields, via setting Lock property to Yes (OrgUnit and Region controls' properties)
There is no need to handle AfterUpdate event to modify OrgUnit and Region controls as soon as they automatically retrieved with the query above set as Form.RecordSource.
BTW you can paste the SQL to Query builder and check whether it is working properly (I'm pretty sure it does bkz I have a working form based on this).
Thanks for the further elaboration. That made a lot of things very clear. The Query you gave me is working just fine in the SQL-Builder. Unfortunately, when I enter it in the form and do the steps and save the whole thing, it won't to what it should be doing. I don't receive an error, just a "bing-sound". Additionally, I can't change the CostCenter.
I was doing exactly how you described it. Sorry, I am still bothering you with this problem.
thanks
Thanks for the further elaboration. That made a lot of things very clear. The Query you gave me is working just fine in the SQL-Builder. Unfortunately, when I enter it in the form and do the steps and save the whole thing, it won't to what it should be doing. I don't receive an error, just a "bing-sound". Additionally, I can't change the CostCenter.
I was doing exactly how you described it. Sorry, I am still bothering you with this problem.
thanks
Nope, the Query isn't running right. The fields we are trying to include in our SQL-Query are empty (CostCenter.Region and CostCenter.OrgUnit).
Nope, the Query isn't running right. The fields we are trying to include in our SQL-Query are empty (CostCenter.Region and CostCenter.OrgUnit).
Hi, there.
I think I should take a look at this. Send me a copy of your db via email (I will open my vCard for download).
Hi, there.
I think I should take a look at this. Send me a copy of your db via email (I will open my vCard for download).
Thanks Fish for this intensive help, I finally could solve the problem.
For the others: The Select-Statement works just fine, the problem in my case was just the relationships.
Regards and thanks,
Alive
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John |
last post by:
Dear all,
It been more than 3 days I am trying to debug this program, I
interpret it using activePerl and it is giving (perl -wc
code_process.pl) no error syntax but when I put it online, change...
|
by: Richard Cornford |
last post by:
I am interested in hearing opinions on the semantic meaning of FORM
(elements) in HTML.
I have to start of apologising because this question arose in a context
that is not applicable to the...
|
by: Targa |
last post by:
Trying to total some price fields in a form but doesnt work when all the
referenced form fields dont exisit.
This is for an invoice - pulled prom a database and the form doesnt always
contain the...
|
by: Raposa Velha |
last post by:
Hello to all!
Does any of you want to comment the approach I implement for
instantiating a form? A description and an example follow.
Cheers,
RV
jmclopesAThotmail.com replace the AT with the...
|
by: RAJ |
last post by:
hi
plz tell me how to know "how window is going to close"...
i have to right code for X button of forms...
plz telll me
thanks
bye
|
by: Gary Miller |
last post by:
Does anyone know how to detect a modeless form on closing by the form that
invoked the modeless form?
form.Show();
|
by: Alex Sibilev |
last post by:
Hello,
I have a really weird problem I've been trying to solve it without any luck
for the last couple of hours :(
I'm writing a "conference board" application (quite similar to ASP.NET...
|
by: ortaias |
last post by:
I have a form which calls up a second form for purposes of data entry.
When closing the data entry form and returning to the main form, things
don't work as expected.
When I return to the main...
|
by: Miro |
last post by:
I will try my best to ask this question correctly. I think in the end the
code will make more sence of what I am trying to accomplish. I am just not
sure of what to search for on the net.
I...
|
by: NeoPa |
last post by:
Introduction
The first thing to understand about Sub-Forms is that, to add a form onto another form takes a special Subform control. This Subform control acts as a container for the form that you...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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,...
| |