SetValue in 2003v transfer to 2007v?

Uvuriel03

Registered User.
Local time
Today, 00:00
Joined
Mar 19, 2008
Messages
115
I have several macros in a database I was creating with Access 2003. My boss switched us all over to the 2007 version, and now I guess you can't use the SetValue macro option in the same way.

I was using it to set a field in one form to match what was in a field on another open form. Now it won't work, and I get an error message when I try to run the form with the macro in it.

I don't know how to code what it is I want the form to do. If anybody has any suggestions, they would be GREATLY appreciated.

Thanks,
Rachel
 
Thanks... I already found that link though.

I figured out how to find it. I'm still getting the error message when I try to run that particular macro though. I've made the folder my database is in into a trusted location, but still no good. The weird thing is that the error that keeps coming up is completely unrelated to anything in that particular macro.
 
Are you running it as an ac2003 file or did you convert it to ac2007? Did you convert or Import it?
 
I'm running it as an '07 file, and I just opened up the '03 in the '07 version, so I assume it's converted. I'm not familiar with how '07 works at all yet. :(
 
ac07 can run an ac03 directly without converting it. What error are you getting? Do you have any MISSING references?
 
There should be a way to put the setvalue kind of function into VBA coding, right?
 
When I try to open the form, I actually don't get an error, I get a request for a parameter.

It asks for these three in a row, if I don't type anything in and just hit enter:
Code:
Forms!frmAFPRINTTRUCKREPORTS.Start_Dates
Code:
Forms!frmAFPRINTTRUCKREPORTS.End_Dates
Code:
qryAFTRUCKRPTUNION.NEXTTRUCK
If I click "Cancel" on any one of the three, I get this:
Code:
"Microsoft Office can't find the form 'frmAFNEXTTRUCK' referred to in a macro expression or Visual Basic code."

Macro Name:
mcrAFTRUCKOUT
Condition:
True
Action Name:
SetValue
Arguments:
[Forms]![frmAFOUT]![TRUCK NUMBER], [Forms]![frmAFNEXTTRUCK]![Current Truck]
And then it has the option to Stop all Macros.

frmAFOUT is a form with several unbound text boxes into which I dump data that the user determines by pushing a button. This button brings up a query-based form which asks them which pallet ID they want to enter. They type in a number, and it brings up a form (frmAFCONFIRMPALLET) displaying that pallet's information. On that form, there's a button that says "Send to Shipper", and when they select that, certain values from frmAFCONFIRMPALLET are transferred to certain fields on frmAFOUT and then frmAFCONFIRMPALLET is closed.

frmAFNEXTTRUCK is a form based on a union query that compares the most recent truck numbers from the in table and the out table and selects the higher of the two. This highest truck number is then displayed on this form, and it is used to determine what the NEXT truck number will be. (AKA if 10 is the highest in the out table, and 12 is the highest on the in table, then 13 will be the next truck number.)

frmAFPRINTTRUCKREPORTS is a form completely unrelated to the one I'm trying to open.
 
Last edited:
There should be a way to put the setvalue kind of function into VBA coding, right?
Absolutely! Just open the macro in design mode and then SaveAs module. Is the frmAFPRINTTRUCKREPORTS form open when this is run?
 
No, it's not open at all. Nothing is open to start with--I'm just trying to open frmAFOUT.
 
Okay, here's what I get when I do that:

Code:
Option Compare Database

'------------------------------------------------------------
' mcrAFTRUCKOUT
'
'------------------------------------------------------------
Function mcrAFTRUCKOUT()
On Error GoTo mcrAFTRUCKOUT_Err

    DoCmd.OpenForm "frmAFNEXTTRUCK", acNormal, "", "", acReadOnly, acHidden
    Forms!frmAFOUT![TRUCK NUMBER] = Forms!frmAFNEXTTRUCK![Current Truck]
    DoCmd.Close acForm, "frmAFNEXTTRUCK"


mcrAFTRUCKOUT_Exit:
    Exit Function

mcrAFTRUCKOUT_Err:
    MsgBox Error$
    Resume mcrAFTRUCKOUT_Exit

End Function
 
Well...this line in the macro:
Forms!frmAFOUT![TRUCK NUMBER] = Forms!frmAFNEXTTRUCK![Current Truck]
...wants forms frmAFOUT and frmAFNEXTTRUCK open before it runs. Can you post the db maybe so we can have a better look? Remove any sensitive data first.
 
And I've been playing with it more... As far as I can tell, the error actually traces all the way back to the query.

qryAFNEXTTRUCK

For some reason, it doesn't seem to want to work correctly...
 
Holy cow, I am massively blind. I figured out the problem--the qryAFNEXTTRUCK query was tied to the wrong union query.

Sorry for the massive amount of confusion. *palmforhead*
 
Last edited:
It looks to me as though you have the problems in ac03 as well. I use ac02 but it still wants additional parameters.
 
Holy cow, I am massively blind. I figured out the problem--the qryAFNEXTTRUCK query was tied to the wrong union query.

Sorry for the massive amount of confusion. *palmforhead*
Excellent! The important thing is that you are back up and running. ;)
 
Thanks so much for your help. ^_^

Now, on to the rest of the kinks!
 
You're very welcome. Sometimes all one needs is a sounding wall.
 

Users who are viewing this thread

Back
Top Bottom