Trouble passing value across forms - syntax?

brewpedals

Registered User.
Local time
Today, 12:36
Joined
Oct 16, 2002
Messages
32
Hi all,

I have a form that I would like to use to edit existing records and create new ones. I have written code for a new record button and I am having trouble passing a value from one form to the other. I get a 2427 "...expression that has no value..." error.

Can you look it over for me please?

Here is the code on the new record button on my main form.

Code:
    stDocName = "frm_DMSS"
    DoCmd.OpenForm stDocName, , , acFormAdd
    Forms!frm_DMSS!Form.Caption = "Create a NEW Document record."
    Forms!frm_DMSS!txt_OwnerID = Forms!frm_DetectIdleTime!UserID.Value
    Forms!frm_DMSS!Date = Date

* I use frm_DetectIdleTime to store the current UserID in an unbound form.
* frm_DMSS is the form I want use to create and edit records.

The error occurs on the formopen code when I try to set another variable based upon the value in the target control.

strOwnerID = Me.txt_OwnerID.Value

Thanks so much for your time.
 
brew,

When you get that error on this expression, it means what it says:

Me.txt_OwnerID.Value has not value.

strOwnerID = Me.txt_OwnerID.Value

What you need to do is set a breakpoint on the New Record button
and view the contents of: Forms!frm_DetectIdleTime!UserID.Value

It is probably Null.

Is form frm_DetectIdleTime open?
Does UserID really have a value?

The Debugger could help you here.

Or Compact/Repair, ZIP and attach to your post.

Wayne
 
In the meantime, I'll take a guess.

Change...

Forms!frm_DMSS!Form.Caption = "Create a NEW Document record."

to...

Forms!frm_DMSS.Caption = "Create a NEW Document record."

Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom