Fill in table using an iff statement from a sub form

G

Guest

I have a subform that has a text box "txtProgramName" that has
"=IIf(Forms!frmContracts!RFQType='R',"NGSS Material Replacements","NGSS COSAL
Material Replacements")" as its Control Source.

I need the correct choice to fill in the table tblLineItem.

How is this done?
 
M

Mark A. Sam

Many ways, but here is one. On the Dirty property of the subform:

[myTextBox] =IIf(Forms!frmContracts!RFQType='R',"NGSS Material
Replacements","NGSS COSAL
Material Replacements")

Or you can place it in the AfterUpdate event of a control on the subform.
[myTextBox] is the Textbox on the subform you wish to populate. If you want
to populate [txtProgramName] then you need to clear the ControlSource
property of the textbox.

God Bless,

Mark A. Sam
 
G

Guest

Hi Mark,

Thanks for answering. Apparently I didn't explain myself very well. I
already have the code " [myTextBox] =IIf(Forms!frmContracts!RFQType='R',"NGSS
Material
Replacements","NGSS COSAL Material Replacements") in my form.

What is not happening is the data is not being put into the source table.
So, although I see "NGSS Material Replacements" in the text box on the form,
the data is not being put into the underlying table. I thought it did this
automatically, but it isn't happening.

Any other suggestions?

Mark A. Sam said:
Many ways, but here is one. On the Dirty property of the subform:

[myTextBox] =IIf(Forms!frmContracts!RFQType='R',"NGSS Material
Replacements","NGSS COSAL
Material Replacements")

Or you can place it in the AfterUpdate event of a control on the subform.
[myTextBox] is the Textbox on the subform you wish to populate. If you want
to populate [txtProgramName] then you need to clear the ControlSource
property of the textbox.

God Bless,

Mark A. Sam



Nanette said:
I have a subform that has a text box "txtProgramName" that has
"=IIf(Forms!frmContracts!RFQType='R',"NGSS Material Replacements","NGSS
COSAL
Material Replacements")" as its Control Source.

I need the correct choice to fill in the table tblLineItem.

How is this done?
 
M

Mark A. Sam

Hello Nanette,

Is it your understanding that setting the ControlSource value of a textbox
to "= WhateverValue" will place data into a table? It won't. The purpose
is to display a value in a textbox for the user's information. If you want
to place the data into a table, you should use Code to place it into the
table by populated a control on a form, like in the example I gave or
through DAO, which are methods for addressing tables.



Nanette said:
Hi Mark,

Thanks for answering. Apparently I didn't explain myself very well. I
already have the code " [myTextBox]
=IIf(Forms!frmContracts!RFQType='R',"NGSS
Material
Replacements","NGSS COSAL Material Replacements") in my form.

What is not happening is the data is not being put into the source table.
So, although I see "NGSS Material Replacements" in the text box on the
form,
the data is not being put into the underlying table. I thought it did this
automatically, but it isn't happening.

Any other suggestions?

Mark A. Sam said:
Many ways, but here is one. On the Dirty property of the subform:

[myTextBox] =IIf(Forms!frmContracts!RFQType='R',"NGSS Material
Replacements","NGSS COSAL
Material Replacements")

Or you can place it in the AfterUpdate event of a control on the subform.
[myTextBox] is the Textbox on the subform you wish to populate. If you
want
to populate [txtProgramName] then you need to clear the ControlSource
property of the textbox.

God Bless,

Mark A. Sam



Nanette said:
I have a subform that has a text box "txtProgramName" that has
"=IIf(Forms!frmContracts!RFQType='R',"NGSS Material Replacements","NGSS
COSAL
Material Replacements")" as its Control Source.

I need the correct choice to fill in the table tblLineItem.

How is this done?
 
G

Guest

Hi Mark,

Guess I didn't understand your first message. I tried putting the code
"[txtProgramName] =IIf(Forms!frmContracts!RFQType='R',"NGSS Material
Replacements","NGSS COSAL Material Replacements")" into the Dirty option on
the SubForm, made sure the ControlSource was empty, and now I'm getting the
message that the Macro can't be found.

I've only been working full time in Access databases for 6 months now and am
wondering if I should try something different. I just don't seem to
understand some things :-((


Mark A. Sam said:
Hello Nanette,

Is it your understanding that setting the ControlSource value of a textbox
to "= WhateverValue" will place data into a table? It won't. The purpose
is to display a value in a textbox for the user's information. If you want
to place the data into a table, you should use Code to place it into the
table by populated a control on a form, like in the example I gave or
through DAO, which are methods for addressing tables.



Nanette said:
Hi Mark,

Thanks for answering. Apparently I didn't explain myself very well. I
already have the code " [myTextBox]
=IIf(Forms!frmContracts!RFQType='R',"NGSS
Material
Replacements","NGSS COSAL Material Replacements") in my form.

What is not happening is the data is not being put into the source table.
So, although I see "NGSS Material Replacements" in the text box on the
form,
the data is not being put into the underlying table. I thought it did this
automatically, but it isn't happening.

Any other suggestions?

Mark A. Sam said:
Many ways, but here is one. On the Dirty property of the subform:

[myTextBox] =IIf(Forms!frmContracts!RFQType='R',"NGSS Material
Replacements","NGSS COSAL
Material Replacements")

Or you can place it in the AfterUpdate event of a control on the subform.
[myTextBox] is the Textbox on the subform you wish to populate. If you
want
to populate [txtProgramName] then you need to clear the ControlSource
property of the textbox.

God Bless,

Mark A. Sam



I have a subform that has a text box "txtProgramName" that has
"=IIf(Forms!frmContracts!RFQType='R',"NGSS Material Replacements","NGSS
COSAL
Material Replacements")" as its Control Source.

I need the correct choice to fill in the table tblLineItem.

How is this done?
 

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