How to Set Temporary Value (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 21:36
Joined
Sep 21, 2011
Messages
14,047
Right, from what I can see

Your tbl_hm has no record?, so you can never filter to a record of any type.
Your tbl_mb has records, not all match.

The only reason you see the value selected from the subformnonstandard form is that you assign the current LcontrolsID to TempVars]![temVarLControl] and then LControlsID has a default value of =[TempVars]![temVarLControl], and as no record exists with the selected value, you are on anew record and see the default value. If you remove that, it behaves the same as Form_hm.
 

tihmir

Registered User.
Local time
Today, 14:36
Joined
May 1, 2018
Messages
257
Right, from what I can see

Your tbl_hm has no record?, so you can never filter to a record of any type.
Your tbl_mb has records, not all match.

The only reason you see the value selected from the subformnonstandard form is that you assign the current LcontrolsID to TempVars]![temVarLControl] and then LControlsID has a default value of =[TempVars]![temVarLControl], and as no record exists with the selected value, you are on anew record and see the default value. If you remove that, it behaves the same as Form_hm.
Is there a way when I press the button cmdHM to open the form "Form_hm" to the same LControlsID as on the form "subformNonStandard" and to add in the form "Form_hm"?
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:36
Joined
Sep 21, 2011
Messages
14,047
Is there a way when I press the button cmdHM to open the form "Form_hm" to the same LControlsID as on the form "subformNonStandard" and to add in the form "Form_hm"?

Yes, you could do the same as you are doing with the _mb form.
Assign the Tempvar to Me.LControlsID, and put the same default value for that control on the _hm form.?

As there is no record to match, all you are doing is setting a new record's value to that of the TempVar. if a record existed with that value then you would be shown those records.

I am not saying this is the best way, but it is one way, which you are comfortable with using, especially as you are setting the default value on the destination form.

HTH
 

tihmir

Registered User.
Local time
Today, 14:36
Joined
May 1, 2018
Messages
257
Yes, you could do the same as you are doing with the _mb form.
Assign the Tempvar to Me.LControlsID, and put the same default value for that control on the _hm form.?
As there is no record to match, all you are doing is setting a new record's value to that of the TempVar. if a record existed with that value then you would be shown those records.
I am not saying this is the best way, but it is one way, which you are comfortable with using, especially as you are setting the default value on the destination form.
HTH
What should the code look like on click on the button cmdHM?
I'm trying with this, but nothing
Code:
     Dim tvLControlsID As TempVars
    Me.LControlsID = TempVars!tvLControlsID
    DoCmd.OpenForm "Form_hm"
On the form "Form_hm" in the field LControlsID I set Default Value =[TempVars]![tvLControlsID]
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:36
Joined
Sep 21, 2011
Messages
14,047
Well, I think you would still want the Where clause in case a record with that ID exists?
I would expect it would be along the lines of

Code:
[TempVars]![temVarLControl]= Me.LControlsID
DoCmd.OpenForm "Form_hm", , , "[LControlsID]=" & Me.LControlsID

and set the default value for LControlsID as you have done for form_mb ?

FWIW, the one variable I have never dimmed has been a TempVar. Only just realised this.:eek:
 

tihmir

Registered User.
Local time
Today, 14:36
Joined
May 1, 2018
Messages
257
Yes, I need the same result as in cmdMB and Form_mb
When I add this code on my Access 2019:
[TempVars]![temVarLControl]= Me.LControlsID

DoCmd.OpenForm "Form_hm", , , "[LControlsID]=" & Me.LControlsID
it shows my Run time error: 32538: TemVar can only stor data :banghead:
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 21:36
Joined
Sep 21, 2011
Messages
14,047
Well, the DoCmd needs to be on a new line

Try adding the .Value to the tempvar

As I mentioned before I just use the format below

Code:
tempvars("tt")=123
? tempvars("tt")
123
 

tihmir

Registered User.
Local time
Today, 14:36
Joined
May 1, 2018
Messages
257
The code finally works!
Code:
 TempVars("temVarLControl") = LControlsID.[COLOR=Red]Value[/COLOR]
    DoCmd.OpenForm "Form_hm", , , "[LControlsID]=" & Me.LControlsID
Thanks, Gasman
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:36
Joined
Sep 21, 2011
Messages
14,047
I would stay consistent and use Me.LControlsID in both places.?
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:36
Joined
Sep 21, 2011
Messages
14,047
In this case I get Run-time error 32538

OK, my apologies.:eek: Access thinks you are trying to assign an object not it's value.
One of the few times you need to specify the value property I believe.?
 

Users who are viewing this thread

Top Bottom