473,378 Members | 1,451 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,378 software developers and data experts.

Matching a value from one form to another

Hello all,
Here is what i am trying to do doing:
Form A & Form B
Form A:
compressor_id = 23
Description: test

Form B:
stage_id = 12
compressor_fk = compressor_id
Description: test2

I create a button in Form A so when I click it it will take me to Form
B. I have the relationship b/w my tables, where COMPRESSOR (name of
table) compressor_id = compressor_fk in the STAGES table. That is
working fine. Now what I want is: when I click on the button that takes
me to Form B, it will automatically display my compressor_id into the
compressor_fk. Right now, I can type the compressor_id into my Form B
and it will recognize it w/o any problem. I tested by going to the
tables and I can see the values are matching (compressor_id and
compressor_fk).
Summary: I want it to automatically display the compressor_id in my
Form B, I do not want to type it.

Please help, thank you

Jul 18 '06 #1
12 2797
"erick-flores" <ch**********@hotmail.comwrote in
news:11**********************@h48g2000cwc.googlegr oups.com:
Hello all,
Here is what i am trying to do doing:
Form A & Form B
Form A:
compressor_id = 23
Description: test

Form B:
stage_id = 12
compressor_fk = compressor_id
Description: test2

I create a button in Form A so when I click it it will take me
to Form B. I have the relationship b/w my tables, where
COMPRESSOR (name of table) compressor_id = compressor_fk in
the STAGES table. That is working fine. Now what I want is:
when I click on the button that takes me to Form B, it will
automatically display my compressor_id into the compressor_fk.
Right now, I can type the compressor_id into my Form B and it
will recognize it w/o any problem. I tested by going to the
tables and I can see the values are matching (compressor_id
and compressor_fk).
Summary: I want it to automatically display the compressor_id
in my Form B, I do not want to type it.

Please help, thank you
In the OnClick Event on form A you need to add a command which
copies the value of the control on form A to the equivalent
Control on form B, after the command that opens form B.

Forms!form_B!compressor_fk = me.compressor_id
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jul 18 '06 #2
Thank for your answer

I did what you told me but I am getting an error message:

Private Sub Command22_Click()
On Error GoTo Err_Command22_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "STAGES"
DoCmd.OpenForm stDocName ', , , stLinkCriteria
forms!Stages!comp_fk = Me.comp_pk

Exit_Command22_Click:
Exit Sub

Err_Command22_Click:
MsgBox Err.Description
Resume Exit_Command22_Click

End Sub

The line "forms!Stages!comp_fk = Me.comp_pk"
----!Stages <---- it higlight this, and says:
Compile error:
Qualifier must be collection

Stages is the name of my Form B

Any suggestions? I am going crazy with this if you can help I will
really aprecciate

Thanks

Jul 18 '06 #3
I am also trying:

Private Sub Command22_Click()
On Error GoTo Err_Command22_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "STAGES"

stLinkCriteria = "[comp_fk]=" & Me![comp_pk]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command22_Click:
Exit Sub

Err_Command22_Click:
MsgBox Err.Description
Resume Exit_Command22_Click

End Sub

This is working fine, it just wont display the value from the Form A to
the Form B. Is there an option to display the value from the Form A to
Form B? because the "[comp_fk]=" & Me![comp_pk] its working but its not
displaying the value. I wanna see my value displayed from form A to
form B.

Please helppp :'(

Jul 18 '06 #4
This is working fine, it just wont display the value from the Form A to
the Form B. Is there an option to display the value from the Form A to
Form B? because the "[comp_fk]=" & Me![comp_pk] its working but its not
displaying the value. I wanna see my value displayed from form A to
form B.

Please helppp :'(
If you're trying to _copy_ the value, then you have to set it

Forms![MyFormB]![ControlName]=Forms![MyOpenFormA]![ControlName]

Jul 19 '06 #5
"erick-flores" <ch**********@hotmail.comwrote in
news:11**********************@35g2000cwc.googlegro ups.com:
Thank for your answer

I did what you told me but I am getting an error message:

stDocName = "STAGES"
DoCmd.OpenForm stDocName ', , , stLinkCriteria
forms!Stages!comp_fk = Me.comp_pk
The line "forms!Stages!comp_fk = Me.comp_pk"
----!Stages <---- it higlight this, and says:
Compile error:
Qualifier must be collection

Stages is the name of my Form B
comp_fk is the name of the control on that form, which may be
different from the field name in the table?
same question about comp_pk.

It may also be a timing issue, the form may not open quickly
enough. Try a doevents statement between the Docmd.Openform line
and the one which sets the variable.

See also mr Linden's notes about [] around the elements in the
expression. They are necessary only with spaces and punctuation
in element names, but it doesn't hurt to include them.

since the code is in form A, me. should work, as a reference to
the form, but you can go with the long notation too..
>
Any suggestions? I am going crazy with this if you can help I
will really aprecciate

Thanks


--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jul 19 '06 #6

Hello

Thank you guys for helping me. I finally figured out.

Jul 19 '06 #7
OK, So I am getting another problem. I dont know whats happend with
this, but sometimes it works sometimes it doesnt. Its driving me crazy,
but anyways. When I click the button to open Form B it is showing the
foreign key from my Form A BUT it its also automatically displaying the
primary ID of Form B. This primary key i set it up =Autonumber. This
was not happening before. Any suggestions'???

Jul 19 '06 #8
"erick-flores" <ch**********@hotmail.comwrote in
news:11**********************@75g2000cwc.googlegro ups.com:
OK, So I am getting another problem. I dont know whats happend
with this, but sometimes it works sometimes it doesnt. Its
driving me crazy, but anyways. When I click the button to open
Form B it is showing the foreign key from my Form A BUT it its
also automatically displaying the primary ID of Form B. This
primary key i set it up =Autonumber. This was not happening
before. Any suggestions'???
I can tell you why it is happening now and wasn't happening
before, and you can decide whether to handle it.

Before, when you opened form B, the autonumber did not appear
UNTIL you typed something in any textbox on the form.

Because you have some code that types something into one of the
textboxes, it makes the autonumber appear as soon as you open
the form.

why are you displaying the ID on the form anyways? It is not
reccommended.
Jul 19 '06 #9
Hello Bob

That was not the real problem, I didnt explain very well in the last
reply. The problem is: It will display the SAME primary key in Form B
everytime I click on the button to go from Form A to Form B. So
obviusly it is changing the same record all the time I switch to Form
B. i do not knwo why this is happend, because the option to that
primary key is Autonumber, so it supposed to display a different number
everytime the form opens, or not? maybe I am doing something wrong. I
tried both Autonumber (increment, random) and I got the same
environment.

why are you displaying the ID on the form anyways? It is not
reccommended.
I am only displaying the ID to see if its working, just for
functionality issues. But I will remove the ID from the forms once I
know its working well, once all my forms are related through the pk and
fk. I guess I will just select the "hide = yes" option for that field.

Thanks

Jul 20 '06 #10

I found something interesting. The primary key in the Form B is
displaying the same one. If I go to the tables and manually add a new
record to the table that is attach to Form B the Autonumber will work
perfect, it will be incrementing. BUT when I go back and run the forms
it will display the same pk that it displayed the last time (will not
follow the autonumber from the those record that I add in the tables).
Dont know why this is happend.
I was thinking maybe in writing some code, in the clickevent, to set
the pk from Form B to a ramdon number everytime it opens, to eliminate
this problem. Do you know how to write this random code?

Jul 20 '06 #11
OK, I think I know where the problem is. When Form B opens it need to
automatically add a new record (set all the fields to blank[no data],
only the pk from Form B will be display), insted of looking at the ones
that I've already enter. Do you know how to do this?

Jul 20 '06 #12
"erick-flores" <ch**********@hotmail.comwrote in
news:11**********************@s13g2000cwa.googlegr oups.com:
OK, I think I know where the problem is. When Form B opens it
need to automatically add a new record (set all the fields to
blank[no data], only the pk from Form B will be display),
insted of looking at the ones that I've already enter. Do you
know how to do this?

Yes. There are two ways to do this. The first is to set the
..dataentry property to Yes in the form's design view and save it.

The second way is to tell the form to open on a new record, this is
a parameter of the docmd.openform
docmd.OpenForm "Form2",,,,acFormAdd

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jul 20 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hennie | last post by:
I apologise if this is a stupid question, but I would appreciated any help on this subject. I want to create a view (VIEW_1 in example below) where I take numeric values from a field in one...
16
by: Martin Jørgensen | last post by:
Hi, Short question: Any particular reason for why I'm getting a warning here: (cast from function call of type int to non-matching type double) xdouble = (double)rand()/(double)RAND_MAX;
6
mmarif4u
by: mmarif4u | last post by:
Hi everyone. i make a page that a user input thier icnumber with confirm ic number, it saves the data to mysql db with current date and a random access code generated automatically, NOW i have...
18
by: Drayno241 | last post by:
I'm working in access 2002. I have three tables : 1- District Data (Student ID, name, grade, etc) 2- Rosters (RRec ID,Campus, Teacher ID) 3- Students on Roster(SRec ID, RRec ID, Student ID) ...
1
by: .nLL | last post by:
Hi, i ma trying to change a dropdown box index to mathing value of on another dropdown box in same form. here is the form ...
2
by: .nLL | last post by:
got below script, works fine with IE but fails on opera. my js knowledge is very limited and can't find whats wrong with it. ---------------------------------------------- function...
5
by: gentsquash | last post by:
In a setting where I can specify only a JS regular expression, but not the JS code that will use it, I seek a regexp component that matches a string of letters, ignoring case. E.g, for "cat" I'd...
2
by: Zetten | last post by:
I've got a script which basically goes line by line through an external file, and hands it to the screen in a slightly parsed form. I'd like to apply another bit of parsing to what's coming in...
0
by: grego9 | last post by:
I have a bit of visual basic code in an excel spreadsheet that I need some help with. I am attempting to search a file called TO Cancellations2.xls for counterparty names and for each counterparty...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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 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.