My Assistant
![]() ![]() |
|
|
May 7 2004, 08:25 PM
Post
#1
|
|
|
UtterAccess Veteran Posts: 321 |
I'm trying to setup a way so that when a user clicks on a command button, it opens a form and puts the current field value in the new record in the next table.
I've setup the one to many relationship with the field between the two tables being equipmentnumber. here's the code i've used. CODE DoCmd.OpenForm "frmSupplyHistory", acNormal, _ , "[EquipmentNumber] = " & EquipmentNumber, acFormAdd, , EquipmentNumber This works for a different form that does the same thing, but won't work for this one. Not sure what i'm doing wrong. Patrick |
|
|
|
May 7 2004, 08:39 PM
Post
#2
|
|
|
UtterAccess Guru Posts: 960 From: Yuma, AZ |
If EquipmentNumber is a string you need to add quotes to the WhereCondition
"[EquipmentNumber] = ' " & EquipmentNumber & " ' " (note spaces added between ' and " for clarity) That's the only thing I see that could be wrong. |
|
|
|
May 7 2004, 08:46 PM
Post
#3
|
|
|
UtterAccess Veteran Posts: 321 |
I've attached a copy of what i'm referring to.
You'll get a couple errors b/c i didn't include all of the forms. If you open it up and double click on the first record's model number, then there are two buttons Place Service Call and Place Supply Call. The service call works, the supply doesn't. Not sure if it's in the relationship or what. I've unhidden the fields so that i can see if the equipmentnumber goes to the new record or not. I know my terminology isn't the greatest, but just don't know how to word things sometimes. It's gotta be something simple b/c i haven't done any work on this db in a while. Thanks, Patrick Edited by: in2god01 on 05.07.04. |
|
|
|
May 7 2004, 09:30 PM
Post
#4
|
|
|
UtterAccess Guru Posts: 960 From: Yuma, AZ |
Where are you trying to open the form? The reference to EquipmentNumber will only work if you are trying to open it from the frmCustomerInformationSubform.
To reference from the main form use [frmCustomerInformationSubform].[Form]![EquipmentNumber] |
|
|
|
May 7 2004, 09:33 PM
Post
#5
|
|
|
UA Forum Administrator Posts: 38,131 From: Birmingham, Alabama USA |
I haven't looked at you attached file ... but ...
You are setting the criteria in the "where" argument .. then trying to open the form to a "new record" ... That dog will never hunt .... RDH |
|
|
|
May 7 2004, 09:34 PM
Post
#6
|
|
|
UtterAccess Veteran Posts: 321 |
man, it's bad when i can't remember how i set this up.
I want to use the equipmentnumber on the FrmEquipmentInformation in the frmSupplyHistory. The Equipmentnumber is on the frmEquipmentInformation, but hidden. When you click on place service call, it inserts it in the frmServiceCall. When i do the same thing to make it go into supplyHistory, it doesn't work. Thanks, Patrick |
|
|
|
May 7 2004, 09:36 PM
Post
#7
|
|
|
UtterAccess Veteran Posts: 321 |
Well, unless the way i'm wording this is wrong, the dog does hunt.. ;-)
If you look at the database you can see the relationships i have setup and sorta what i'm trying to do. Thanks for the help. Patrick |
|
|
|
May 7 2004, 09:36 PM
Post
#8
|
|
|
UA Forum Administrator Posts: 38,131 From: Birmingham, Alabama USA |
Did you see my reply ???
That problem needs to be addressed if you are attempting to pass the value use the OpenArgs ... RDH |
|
|
|
May 7 2004, 09:39 PM
Post
#9
|
|
|
UA Forum Administrator Posts: 38,131 From: Birmingham, Alabama USA |
You can not use the "where" argument to filter the form to a specific record then tell the form to open as a new record ...
That is what you are doing in your code ... RDH |
|
|
|
May 7 2004, 09:40 PM
Post
#10
|
|
|
UtterAccess Veteran Posts: 321 |
The way it works now is when i click on Place Service Call, it opens up the frmServiceCall and uses the EquipmentNumber in the EquipmentInformation form and puts it in the ServiceCall Table for referential integrity.
That's all i'm trying to do. So what i did was made a new table with an autonumber, equipment number to rerence the piece of equipment, and the rest of the data. Then setup the relationship, and changed the place supply call to the way the place service call works. But it won't pass the equipment number over to the supplyhistory table i created. Patrick |
|
|
|
May 7 2004, 09:42 PM
Post
#11
|
|
|
UA Forum Administrator Posts: 38,131 From: Birmingham, Alabama USA |
That's not what the line of code you posted will do ...
"acFormAdd" ... says open the form to a "new record" ... RDH |
|
|
|
May 7 2004, 09:46 PM
Post
#12
|
|
|
UtterAccess Veteran Posts: 321 |
okay.... i finally looked back to a post i did a LONG time ago and found that on the form FrmSupplyHistory, i need to have the OnCurrent to have Me![EquipmentNumber] = Me.OpenArgs.
now when i use the original code, it works. I knew it was something i was missing. Patrick |
|
|
|
May 7 2004, 09:55 PM
Post
#13
|
|
|
UA Forum Administrator Posts: 38,131 From: Birmingham, Alabama USA |
If you are using:
CODE DoCmd.OpenForm "frmSupplyHistory", acNormal, _
, "[EquipmentNumber] = " & EquipmentNumber, acFormAdd, , EquipmentNumber I don't see how it could possibly work ... It should be something like this: CODE DoCmd.OpenForm "frmSupplyHistory", , , , acFormAdd, , Me.EquipmentNumber
RDH |
|
|
|
May 7 2004, 11:49 PM
Post
#14
|
|
|
UtterAccess Veteran Posts: 321 |
Here's the original post i went back to and figured out how to make it work.
There may be an eaiser way, but this worked for me. Thanks for the help. http://www.utteraccess.com/forums/showflat...rt=all&vc=1 Patrick |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 18th June 2013 - 11:09 PM |