473,397 Members | 2,099 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,397 software developers and data experts.

How do I Pass Values to Forms

I tried to pass data to a Form (to open a certain register from a list into a Form). I used DoCmd.OpenForm procedure, and passed the data. but it does not work. Can somebody help me?

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "Fichas", , , "[c_ficha] = [Forms]![FrmMenu]![SubQryInfoUtilProximasPartidas]![c_ficha]"
And I watched the correct value in c_ficha, when it was called.
Oct 24 '11 #1
18 1989
NeoPa
32,556 Expert Mod 16PB
Alvaro, We can guess that [FrmMenu] is a form, but what are :
  1. [SubQryInfoUtilProximasPartidas]?
  2. [c_ficha]?

You tell us it does not work, but you give us no clues as to what actually happened. In what way doesn't it work? What do you see when it runs?

You need to provide us with a question if you want us to provide an answer.
Oct 24 '11 #2
Hi, NeoPA,

First of all, thanks a lot for answering.

Expand|Select|Wrap|Line Numbers
  1. [Forms]![FrmMenu]![SubQryInfoUtilProximasPartidas]![c_ficha]
c_ficha is a variable I inherited from the original programer. is the key for the main table, from where I selected the data to fill the form.

the rest was my last trial: is a way to extract the value again from the selected record. In any case, I tried also:

Expand|Select|Wrap|Line Numbers
  1. "c_ficha=78"
,
Expand|Select|Wrap|Line Numbers
  1. Dim recordID As Integer
  2. recordID = c_ficha
  3. DoCmd.OpenForm "Fichas", , , "[c_ficha] = recordID"
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "Fichas", , , "name = nameSelected AND lastName = lastNameSelected" 
In every case I watched the values coming into the DoCmd.OpenForm invocation, and they were OK, and the Form I called came out empty.
Oct 25 '11 #3
NeoPa
32,556 Expert Mod 16PB
That's a good reply Alvaro, but I still have some points I don't understand. Let me see if I can help with some more numbered questions. Please show the question number by each answer :
  1. [Forms]![FrmMenu]![SubQryInfoUtilProximasPartidas]![c_ficha]
    What is [SubQryInfoUtilProximasPartidas] from the expression above?
    SubQry indicates a subquery, but subqueries wouldn't make sense as a control on a form. A subform may, but the naming is strange for a subform. Please explain.
  2. What is [c_ficha] from the expression above?
    If [SubQryInfoUtilProximasPartidas] is a subform then it could be a control on that subform, but what type of control and what type of data does it reflect (Numeric? String? Date?)?
  3. Is [C_Ficha] a field on the record that [FrmMenu] has as a record source?

With clear answers to these questions I think we can resolve your problem together.
Oct 25 '11 #4
Hi again, NeoPa.

1. Funny as it is, [SubQryInfoUtilProximasPartidas] is a Form (as I told you before, I inherited this development :-))
2. [c_ficha] Is an Integer, which indicates the Key of the main table (named Fichas) I guess the first developer called it as a short for "code_of_the_ficha", though I wanted to change it to [PeopleID]. But the amount of code to change (and the inestability) would have been major!
3. As in 2., [c_ficha] is the key autonumeric integer value, in Fichas ([Fichas].[c_ficha])

Thanks again.
Oct 25 '11 #5
NeoPa
32,556 Expert Mod 16PB
Let me first send you off to look at Referring to Items on a Sub-Form.

When you've read that you can tell me the names of both the SubForm control on [FrmMenu] and the actual form contained within that SubForm.

#2 I need you to answer again. I didn't ask what is [C_Ficha] generally, but what specifically it is with reference to the expression above. I am expecting to see that it is a control of some kind on a form.

#3 I asked wrongly. I meant to say :
Is [C_Ficha] a field on the record that [Fichas] has as a record source?

I assume your answer indicates a Yes.

I don't have all the answers I need for a full answer, but I can give one that at least shows the correct format :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.OpenForm(FormName:="Fichas", _
  2.                     WhereCondition:="[C_Ficha] = " & Me.???!C_Ficha)
Where ??? is the name of your SubForm control (which may or may not be [SubQryInfoUtilProximasPartidas]).
Oct 25 '11 #6
Hi, NeoPa,

Sorry for the delay in getting back to you.

FOA, thanks for the clarification, I actually did not pay attention to the fact I was not giving an object.

Second, the problem is now in a "type mismatch" situation:
Expand|Select|Wrap|Line Numbers
  1. Call DoCom.OpenForm(FormName:="Fichas", WhereCondition:="[c_ficha] = " & Me.nombre![c_ficha] & ";")
This is the line I came up with. nombre (name in Spanish) is the object from which the event is taken.

As far as I can understand,
Expand|Select|Wrap|Line Numbers
  1. Me.nombre
defines the object within the Form. When I added the ![c_ficha], I refered it to the value of the c_ficha field of nombre. Why should this be mismatched?

I used a temporal variable (personaID as integer) to receive the value I was expecting. And it works, but, when I use it to build up the WhereCondition, it stops and warns "type mismatch".
Oct 30 '11 #7
I tried to work this out, but to no avail. This is the code I wrote:
Expand|Select|Wrap|Line Numbers
  1. Private Sub nombre_DblClick(Cancel As Integer)
  2.     Dim personaID As Integer
  3.     Dim personaName As String
  4.     Dim personaApellido As String
  5.     Dim ConditionSelection As String
  6.  
  7.     personaID = Me.c_ficha
  8.     personaName = Me.nombre
  9.     personaApellido = Me.apellido_p
  10.  
  11.     ConditionSelection = "[c_ficha] = " & personaID
  12.     ConditionSelection = ConditionSelection & " AND [nombre] = " & personaName
  13.     ConditionSelection = ConditionSelection & " AND [apellido_p] = " & personaApellido
  14.  
  15.     Call DoCom.OpenForm(FormName:="Fichas", WhereCondition:=ConditionSelection)
  16.     ' & personaID)
  17. End Sub
  18.  
When looking at it in the Watch window, it looks OK, but again... no object error. If I add the Me! instead of Me., I get a no object error. But then I use a Me.[c_ficha] and it show the values right, but the process breaks, for type mis match.
Oct 30 '11 #8
NeoPa
32,556 Expert Mod 16PB
Alvaro, you don't answer my questions and I cannot understand what you are posting. I ask questions because I need to in order to understand what you are trying to say. If you don't answer my questions then other comments are not helpful. You can write a book of information, but if you don't answer my questions I am not able to help you. I understand explaining things can be difficult, which is why I ask those clever questions. All you have to do is answer the questions and we can proceed. That should be clear now.

When you introduce new items (such as Me.Nombre - which is certainly an object on the form. Such objects are controls. What type of control I don't know so you need to explain). I cannot help much if you introduce new items without explaining where they fit in. I really can't do much more with post #4 at this time.

For post #5, your code tells me that [Nombre] and [Appellido_P] are both string values. From there I can say that your ConditionSelection should be set up differently for these fields (See Quotes (') and Double-Quotes (") - Where and When to use them). Also, although it does no harm (and provided helpful information in this case), saving these values into variables for the purposes of adding them into this string is unnecessary.

Your procedure could be written as :
Expand|Select|Wrap|Line Numbers
  1. Private Sub nombre_DblClick(Cancel As Integer)
  2.     Dim ConditionSelection As String
  3.  
  4.     With Me
  5.         ConditionSelection = "([c_ficha] = " & .C_Ficha & ") AND " & _
  6.                              "([Nombre] = '" & .Nombre & "') AND " & _
  7.                              "([Apellido_P] = '" & .Apellido_P & "')"
  8.     End With
  9.     Call DoCom.OpenForm(FormName:="Fichas", WhereCondition:=ConditionSelection)
  10.     ' & personaID)
  11. End Sub
Oct 30 '11 #9
Thanks for your patience. Since I'm a rocky in VB, it takes me time to get to what you are asking. I'll try to answer now.

nombre, apellido_p and c_ficha are text boxes in a subform "SubQryInfoUtilProximasPartidas" that is a result of a query in the form of a spread sheet. All the info comes from a single table called "Ficha". There is a form "MenuFrm" which has the sub form as part of it.

I was confused since these Text Boxes have the same name of the fields in the "Fichas" table.

I know that you don't need to add more lines. I did it only to get the useful information you refer to. I did learn out of them.
Oct 31 '11 #10
NeoPa
32,556 Expert Mod 16PB
Alvaro, many apologies for the delay in responding to this thread. I keep looking at it and finding myself confused and going around in circles trying to make headway. That is not down to your latest post though, just the accumulation of you not understanding me then me not understanding your responses very well. Let's see what we can do from here.

My first question (Sorry - I'm always asking questions but I don't understand your replies very well so I must do so to continue) is how did the code in post #9 work for you? Did you try it? What happened then?

If that wasn't helpful then I need some more precise information from you. You explain that the main controls are TextBoxes, which is good, but TextBoxes can contain data for various types of fields. Am I right to assume that [Nombre] & [Appellido_P] are string fields whereas [C_Ficha] is numeric?

"SubQryInfoUtilProximasPartidas" is a subform, but from Referring to Items on a Sub-Form we see that subform is a word used for both the control and the contained form. What are the names of your control and form in this case?

Alvaro Mendoza:
I was confused since these Text Boxes have the same name of the fields in the "Fichas" table.
One reason why I always rename my controls with a control type prefix (TextBox -> txt; ListBox -> lst; ComboBox -> cbo; etc). It does create extra work but I find it's worth it. I'm not impressed with MS that the wizards leave a default of the same name.

Sorry again for leaving you hanging for so long.
Nov 12 '11 #11
Hi, NeoPa!

First of all, you do not need to apology! It's me the one using your time! So thanks and sorry for the unclear content.

I did try your code, but to no avail. The answer was exactly the same as before: it did not bring up the register I was clicking.

Your assumptions are correct: [Nombre] & [Appellido_P] are strings and [c_ficha] is numeric.

The sub-form is called [SubQryInfoUtilProximasPartidas] and I don't know to which control are you referring. I actually changed the name of the control I was clicking to [nombre_Label] (textbox receiving a string) I hope this was what you were asking.

Now, as I told you before, I inherited this system, and I'm doing my best to fix it. I also renamed some of the variables, but I got into trouble because of inconsistencies I couldn't track... So I went back...

So sorry, and thanks again for the patience.
Nov 13 '11 #12
NeoPa
32,556 Expert Mod 16PB
OK. Now you need to do two things for me.

First of all find the value of ConditionSelection after it's been set up (After line #8). How to Debug SQL String will help you with that. I also need you to let me know what the values are that you expect the filter string (ConditionSelection) to reflect (So I can see if anything is wrong with the SQL).

Next I need you to read the linked article again and understand the difference between a subform control and the form that is used within that control. I need the names of both and a clear indication of which is which. The article explains it quite clearly I think.
Nov 14 '11 #13
Dear NeoPa,

I know the value is what was supposed to be, and actually, it only needs the [c_ficha] value, since it is the key for the Fichas table.

I ran the query, and this is the result:
"([c_ficha] = 11) AND ([Nombre] = 'Gabriel') AND ([Apellido_P] = 'Giulietti')"

I think it's the right one.

Now, the form is FormMenu, the container is [SubQryInfoUtilProximasPartidas]. I don't quite grasp the difference, so the only thing I can tell you is that the Query being showed is [QryInfoUtilProximasPartidas]. The control is within the Subform is [nombreTxtBx], which receives strings.

This is the best I could get. I hope it helps.

Thanks again.

Alvaro
Nov 18 '11 #14
NeoPa
32,556 Expert Mod 16PB
Alvaro Mendoza:
I know the value is what was supposed to be, and actually, it only needs the [c_ficha] value, since it is the key for the Fichas table.
In that case I expect we can forget about the other details.

What is still unclear is why there is no record in the form ([Fichas]) when it is opened. I assume [Fichas] is a form bound to the [Fichas] table yes?

In that case I don't understand why nothing is showing if a [Fichas] record with a [C_Ficha] value of 11 exists (I assume it does).

Why don't you attach your database for me to have a look at for you. I expect there is something missing from your explanation you simply don't know is important to mention. If I can look at it I may find it. If you think that's worth a try then please follow the instructions in Attach Database (or other work).

PS. We could prbably even change your lines #5 to #7 in post #9 to the following if [C_Ficha] is a unique identifier in its own right :
Expand|Select|Wrap|Line Numbers
  1.         ConditionSelection = "([c_ficha] = " & .C_Ficha & ")"
Nov 18 '11 #15
Dear NeoPa,

This is exactly what I don't understand.
Attached Files
File Type: zip DBAish.zip (1.85 MB, 62 views)
Nov 19 '11 #16
NeoPa
32,556 Expert Mod 16PB
I was disappointed to find an ACCDB attached Alvaro. Please read the instructions link again and follow the instructions found there to post a database attachment. I cannot open ACCDB files (as explained in the linked instructions) so I can do nothing yet.
Nov 20 '11 #17
I know, sorry, I read the instructions, but when I tried to save the DB as 2003, it said it could not. Is there an alternative way to do this? I could send the tables, and then the forms (dividing the DB) will that help?
Nov 23 '11 #18
NeoPa
32,556 Expert Mod 16PB
I'm afraid I don't know what's available to you as I've never used 2007 or 2010. However, many members have managed to back-port their databases before. It may be that some part of your database uses 2007 or 2010 specific features. If you make a copy that loses as much as you can while still exhibiting the same problematic behaviour then I would expect a better chance of back-porting to 2003.
Nov 24 '11 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chandru | last post by:
hi I want to know how to pass values from different forms. That is, i created one parent form. from there i opened child form modeless way. Once i close the child form i need some value from...
2
by: Chane | last post by:
hi i have doubt in how to pass values back to the called form. I have two forms, each having a textbox and a button control. First i'm run the first form and click the button, it creates object...
6
by: kath | last post by:
hi everyone......... I have a task, I have fragmented the task into subtask. I have planned to create a class to each subclass and one parent class to handle the sub tasks. Each subclass are...
14
by: krishna1412 | last post by:
Currently i am working in a project of report generation in MS ACCESS. The tables are in sql server 2000. I have to write stored proc in ms access. Illustration: I am having a stored proc...
5
by: codercoder | last post by:
Hello Helpers, I have a question about passing values through multiple C++ functions: Function A calls function B; Function B calls function C; Function C calls function D; D has two values...
2
by: Prashant P | last post by:
help in asp.net to pass values from a page to a frame inside the same page -------------------------------------------------------------------------------- help in asp.net to pass values from a...
15
by: J. Peng | last post by:
Hello, I saw this statement in Core Python Programming book, All arguments of function calls are made by reference, meaning that any changes to these parameters within the function affect the...
6
by: =?Utf-8?B?Unlhbg==?= | last post by:
I am trying to pass a value from a texbox in Form1 to a textbox in Form2 using properties in VS2005 but it doesn't work; please help (project is attached). Code for Game Class: using System;...
0
by: Aniket sonmale | last post by:
i need to pass values to a query in my shell script. my file will contain data as below. 3123213 1234133 4423434 4242343 .
2
by: dougancil | last post by:
I have a page with a gridview and I want to pass the value when a user clicks on a hyperlinked field in the grid to another page. Here is the code for the gridview: <asp:GridView ID="GridView1"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
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...
0
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...
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,...

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.