SetValue

G

Guest

Hello,

I have read through the add in this discussion form but I could not find a
sollution yet. So here is my problem. Some names are in dutch but I will try
to explain with englisch and the dutch word between ( ) behind it.

In a form ([Forms]![Hoofdformulier]![Tester]) I have a field Number A
(Nummer) and a subform ([Testgeval Subform]). In this subform I have two
fields:
1. Name (TestgevalNaam); that is only visible but not enabled and not
locked for a user.
2. Number (Vlgnr); this is a combobox field that the user wil change.

In the field Name I want to enter automaticly a name that is a combination
of the field Number A and the value of the field Number(Vlgnr).

I want to use SetValue in a macro in the On Change event and i filled in:
Item:
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval
Subform].[Form]![TestgevalNaam]

Expression:
=[Forms]![Hoofdformulier]![Tester].[Form]![Nummer] & "-" &
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval Subform].[Form]![Vlgnr]

When I change the value in the combobox it runs the macro but then i get the
message:
The expression you entered contains invalid syntax.
You may have entered an operand without an operator

followed by a window 'Action failed' and in the field arguments is see follow:
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval
Subform].[Form]![TestgevalNaam], 92B-13-1

Firts part should be the field Name(TestgevalNaam), second part is the
result of the combination of the expression that I want.

Now explained all, I can not find what is wrong so I hope someone can help
me with this or give me an other direction to go.

Thank u very much.

Stefan Thorn
 
G

Guest

Your references seem a little messed up. If your main form's name is
Hoofdformulier and your subform's name is [Testgeval Subform], you should
refer to the subform's control like this:

forms![Hoofdformulier]![Testgeval Subform].Form![Vlgnr]

I assume that Tester is a control on the main form. I has no use when
referring to something in the subform.

Barry
 
G

Guest

Hi Barry,

First of all thanks for ur quick responds.

I have used the expression builder to get the references but there is
something I forgot to mention is that Hoofdformulier is the main form.
[Tester] is a tab control and [Testgeval Subform] is the subform in of
[Tester].

The expression is going well because the result should be like 92B-13-1. It
is the first part (Item) that seems to be wrong or something.

Thanks again.

Barry Gilbert said:
Your references seem a little messed up. If your main form's name is
Hoofdformulier and your subform's name is [Testgeval Subform], you should
refer to the subform's control like this:

forms![Hoofdformulier]![Testgeval Subform].Form![Vlgnr]

I assume that Tester is a control on the main form. I has no use when
referring to something in the subform.

Barry

StefanThorn said:
Hello,

I have read through the add in this discussion form but I could not find a
sollution yet. So here is my problem. Some names are in dutch but I will try
to explain with englisch and the dutch word between ( ) behind it.

In a form ([Forms]![Hoofdformulier]![Tester]) I have a field Number A
(Nummer) and a subform ([Testgeval Subform]). In this subform I have two
fields:
1. Name (TestgevalNaam); that is only visible but not enabled and not
locked for a user.
2. Number (Vlgnr); this is a combobox field that the user wil change.

In the field Name I want to enter automaticly a name that is a combination
of the field Number A and the value of the field Number(Vlgnr).

I want to use SetValue in a macro in the On Change event and i filled in:
Item:
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval
Subform].[Form]![TestgevalNaam]

Expression:
=[Forms]![Hoofdformulier]![Tester].[Form]![Nummer] & "-" &
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval Subform].[Form]![Vlgnr]

When I change the value in the combobox it runs the macro but then i get the
message:
The expression you entered contains invalid syntax.
You may have entered an operand without an operator

followed by a window 'Action failed' and in the field arguments is see follow:
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval
Subform].[Form]![TestgevalNaam], 92B-13-1

Firts part should be the field Name(TestgevalNaam), second part is the
result of the combination of the expression that I want.

Now explained all, I can not find what is wrong so I hope someone can help
me with this or give me an other direction to go.

Thank u very much.

Stefan Thorn
 
G

Guest

Let's make sure I understand what you're trying to do. You want to put

Nummer & " - " & Vlgnr into the field called TestgevalNaam.
Is this correct?

Barry

StefanThorn said:
Hi Barry,

First of all thanks for ur quick responds.

I have used the expression builder to get the references but there is
something I forgot to mention is that Hoofdformulier is the main form.
[Tester] is a tab control and [Testgeval Subform] is the subform in of
[Tester].

The expression is going well because the result should be like 92B-13-1. It
is the first part (Item) that seems to be wrong or something.

Thanks again.

Barry Gilbert said:
Your references seem a little messed up. If your main form's name is
Hoofdformulier and your subform's name is [Testgeval Subform], you should
refer to the subform's control like this:

forms![Hoofdformulier]![Testgeval Subform].Form![Vlgnr]

I assume that Tester is a control on the main form. I has no use when
referring to something in the subform.

Barry

StefanThorn said:
Hello,

I have read through the add in this discussion form but I could not find a
sollution yet. So here is my problem. Some names are in dutch but I will try
to explain with englisch and the dutch word between ( ) behind it.

In a form ([Forms]![Hoofdformulier]![Tester]) I have a field Number A
(Nummer) and a subform ([Testgeval Subform]). In this subform I have two
fields:
1. Name (TestgevalNaam); that is only visible but not enabled and not
locked for a user.
2. Number (Vlgnr); this is a combobox field that the user wil change.

In the field Name I want to enter automaticly a name that is a combination
of the field Number A and the value of the field Number(Vlgnr).

I want to use SetValue in a macro in the On Change event and i filled in:
Item:
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval
Subform].[Form]![TestgevalNaam]

Expression:
=[Forms]![Hoofdformulier]![Tester].[Form]![Nummer] & "-" &
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval Subform].[Form]![Vlgnr]

When I change the value in the combobox it runs the macro but then i get the
message:
The expression you entered contains invalid syntax.
You may have entered an operand without an operator

followed by a window 'Action failed' and in the field arguments is see follow:
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval
Subform].[Form]![TestgevalNaam], 92B-13-1

Firts part should be the field Name(TestgevalNaam), second part is the
result of the combination of the expression that I want.

Now explained all, I can not find what is wrong so I hope someone can help
me with this or give me an other direction to go.

Thank u very much.

Stefan Thorn
 
G

Guest

Barry,

Yes, that is correct. But I only want to do this when I choose Vlgnr
otherwis it can happen that in the underlying table only the value of Nummer
will be filled in. Before it was that the default value contained the
reference Nummer & "-" & what causes records in the table without Vlgnr.

Barry Gilbert said:
Let's make sure I understand what you're trying to do. You want to put

Nummer & " - " & Vlgnr into the field called TestgevalNaam.
Is this correct?

Barry

StefanThorn said:
Hi Barry,

First of all thanks for ur quick responds.

I have used the expression builder to get the references but there is
something I forgot to mention is that Hoofdformulier is the main form.
[Tester] is a tab control and [Testgeval Subform] is the subform in of
[Tester].

The expression is going well because the result should be like 92B-13-1. It
is the first part (Item) that seems to be wrong or something.

Thanks again.

Barry Gilbert said:
Your references seem a little messed up. If your main form's name is
Hoofdformulier and your subform's name is [Testgeval Subform], you should
refer to the subform's control like this:

forms![Hoofdformulier]![Testgeval Subform].Form![Vlgnr]

I assume that Tester is a control on the main form. I has no use when
referring to something in the subform.

Barry

:

Hello,

I have read through the add in this discussion form but I could not find a
sollution yet. So here is my problem. Some names are in dutch but I will try
to explain with englisch and the dutch word between ( ) behind it.

In a form ([Forms]![Hoofdformulier]![Tester]) I have a field Number A
(Nummer) and a subform ([Testgeval Subform]). In this subform I have two
fields:
1. Name (TestgevalNaam); that is only visible but not enabled and not
locked for a user.
2. Number (Vlgnr); this is a combobox field that the user wil change.

In the field Name I want to enter automaticly a name that is a combination
of the field Number A and the value of the field Number(Vlgnr).

I want to use SetValue in a macro in the On Change event and i filled in:
Item:
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval
Subform].[Form]![TestgevalNaam]

Expression:
=[Forms]![Hoofdformulier]![Tester].[Form]![Nummer] & "-" &
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval Subform].[Form]![Vlgnr]

When I change the value in the combobox it runs the macro but then i get the
message:
The expression you entered contains invalid syntax.
You may have entered an operand without an operator

followed by a window 'Action failed' and in the field arguments is see follow:
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval
Subform].[Form]![TestgevalNaam], 92B-13-1

Firts part should be the field Name(TestgevalNaam), second part is the
result of the combination of the expression that I want.

Now explained all, I can not find what is wrong so I hope someone can help
me with this or give me an other direction to go.

Thank u very much.

Stefan Thorn
 
G

Guest

I'm not sure why the expression buildier did what it did, but you don't need
a reference to the tab control. In the Item property, put:

[Forms]![Hoofdformulier]![Testgeval Subform].[Form]![TestgevalNaam]

Barry


StefanThorn said:
Barry,

Yes, that is correct. But I only want to do this when I choose Vlgnr
otherwis it can happen that in the underlying table only the value of Nummer
will be filled in. Before it was that the default value contained the
reference Nummer & "-" & what causes records in the table without Vlgnr.

Barry Gilbert said:
Let's make sure I understand what you're trying to do. You want to put

Nummer & " - " & Vlgnr into the field called TestgevalNaam.
Is this correct?

Barry

StefanThorn said:
Hi Barry,

First of all thanks for ur quick responds.

I have used the expression builder to get the references but there is
something I forgot to mention is that Hoofdformulier is the main form.
[Tester] is a tab control and [Testgeval Subform] is the subform in of
[Tester].

The expression is going well because the result should be like 92B-13-1. It
is the first part (Item) that seems to be wrong or something.

Thanks again.

:

Your references seem a little messed up. If your main form's name is
Hoofdformulier and your subform's name is [Testgeval Subform], you should
refer to the subform's control like this:

forms![Hoofdformulier]![Testgeval Subform].Form![Vlgnr]

I assume that Tester is a control on the main form. I has no use when
referring to something in the subform.

Barry

:

Hello,

I have read through the add in this discussion form but I could not find a
sollution yet. So here is my problem. Some names are in dutch but I will try
to explain with englisch and the dutch word between ( ) behind it.

In a form ([Forms]![Hoofdformulier]![Tester]) I have a field Number A
(Nummer) and a subform ([Testgeval Subform]). In this subform I have two
fields:
1. Name (TestgevalNaam); that is only visible but not enabled and not
locked for a user.
2. Number (Vlgnr); this is a combobox field that the user wil change.

In the field Name I want to enter automaticly a name that is a combination
of the field Number A and the value of the field Number(Vlgnr).

I want to use SetValue in a macro in the On Change event and i filled in:
Item:
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval
Subform].[Form]![TestgevalNaam]

Expression:
=[Forms]![Hoofdformulier]![Tester].[Form]![Nummer] & "-" &
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval Subform].[Form]![Vlgnr]

When I change the value in the combobox it runs the macro but then i get the
message:
The expression you entered contains invalid syntax.
You may have entered an operand without an operator

followed by a window 'Action failed' and in the field arguments is see follow:
[Forms]![Hoofdformulier]![Tester].[Form]![Testgeval
Subform].[Form]![TestgevalNaam], 92B-13-1

Firts part should be the field Name(TestgevalNaam), second part is the
result of the combination of the expression that I want.

Now explained all, I can not find what is wrong so I hope someone can help
me with this or give me an other direction to go.

Thank u very much.

Stefan Thorn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top