how to assign variable to unbound field

  • Thread starter Thread starter Christina Gonzalez
  • Start date Start date
OK an UNBOUND CONTROL, UNBOUND TEXTBOX, I think you get
the picture....! Did not get the terminology
right...Does not work, ok let me explain what does not
work mean, this code does not work....

Private Sub txtBOMAdjValue_AfterUpdate()
If Not IsNull(Me.txtBOMAdjValue) Then
intBOMAdjVal = Me.txtBOMAdjValue
End If
End Sub

The user must type a value in this UNBOUND CONTROL!!!
txtBOMAdjValue, intBOMAdjVal is a global variable and
declared as such in a module.

Then i created a command button that does this
calculation.

Private Sub cmdCalculateTotals_Click()

If IsNull(sngBOMTotl = DSum("[Total
Cost]", "qryBOMSummary", "[RFQID] = " & [Forms]!
[frmRFQSummary]![RFQID])) Then
MsgBox "No Values to Calculate for BOM!"
Else
sngBOMTotl = DSum("[Total
Cost]", "qryBOMSummary", "[RFQID] = " & [Forms]!
[frmRFQSummary]![RFQID])
sngBOMTotl = Round(sngBOMTotl, 4)
Form_frmRFQSummary.Refresh
End If

If Not IsNull(intBOMAdjVal) Then
***Me.txtBOMTotal = sngBOMTotl + intBOMAdjVal****
Me.txtBOMTotal = Round(sngBOMTotl, 4)
Form_frmRFQSummary.Refresh
End If

End Sub

The code with the * does not work because Access does not
see this intBOMAdjVal variable because the value is
coming from the UNBOUND CONTROL....HELP! Is there anyone
that has a real answer???????
 
Assuming intBOMAdjVal is dimmed as an integer then this line...

If Not IsNull(intBOMAdjVal) Then

....is pointless as an integer variable can never be null. Only variables of type
variant can be null. So if you were using that to see if the user entered something
in the TextBox then it is incorrect.

Your Private Sub txtBOMAdjValue_AfterUpdate() code is not forcing the user to enter
something into the control unless you have code somewhere else that is doing that?
Otherwise the integer variable will just retain whatever value it was last assigned
to (or zero if it was never assigned a value).

If you want to force an entry in the control why not test it for null when the button
is pressed and then display an error if the control is not filled in? In that case
you don't even need the AfterUpdate code. Just test the control for null when the
button is pressed and then run the rest of your routine if an entry was made.


Christina Gonzalez said:
OK an UNBOUND CONTROL, UNBOUND TEXTBOX, I think you get
the picture....! Did not get the terminology
right...Does not work, ok let me explain what does not
work mean, this code does not work....

Private Sub txtBOMAdjValue_AfterUpdate()
If Not IsNull(Me.txtBOMAdjValue) Then
intBOMAdjVal = Me.txtBOMAdjValue
End If
End Sub

The user must type a value in this UNBOUND CONTROL!!!
txtBOMAdjValue, intBOMAdjVal is a global variable and
declared as such in a module.

Then i created a command button that does this
calculation.

Private Sub cmdCalculateTotals_Click()

If IsNull(sngBOMTotl = DSum("[Total
Cost]", "qryBOMSummary", "[RFQID] = " & [Forms]!
[frmRFQSummary]![RFQID])) Then
MsgBox "No Values to Calculate for BOM!"
Else
sngBOMTotl = DSum("[Total
Cost]", "qryBOMSummary", "[RFQID] = " & [Forms]!
[frmRFQSummary]![RFQID])
sngBOMTotl = Round(sngBOMTotl, 4)
Form_frmRFQSummary.Refresh
End If

If Not IsNull(intBOMAdjVal) Then
***Me.txtBOMTotal = sngBOMTotl + intBOMAdjVal****
Me.txtBOMTotal = Round(sngBOMTotl, 4)
Form_frmRFQSummary.Refresh
End If

End Sub

The code with the * does not work because Access does not
see this intBOMAdjVal variable because the value is
coming from the UNBOUND CONTROL....HELP! Is there anyone
that has a real answer???????
-----Original Message-----
I assume you mean an unbound control as there is no such thing as an unbound field.

What does "does not work" mean? Do you get an error? The syntax provided should
work as long as the control does not have an expression as its ControlSource.




.
 
If Not is Null is NOT the ISSUE...ok, my issue is
assigning a variable to an unbound textbox... I need this
if not is null variable for good reason...which i don't
wish to explain at this time. I understand your
point...however my issue is assigning a variable to an
unbound textbox...
-----Original Message-----
Assuming intBOMAdjVal is dimmed as an integer then this line...

If Not IsNull(intBOMAdjVal) Then

....is pointless as an integer variable can never be null. Only variables of type
variant can be null. So if you were using that to see if the user entered something
in the TextBox then it is incorrect.

Your Private Sub txtBOMAdjValue_AfterUpdate() code is not forcing the user to enter
something into the control unless you have code
somewhere else that is doing that?
Otherwise the integer variable will just retain whatever value it was last assigned
to (or zero if it was never assigned a value).

If you want to force an entry in the control why not
test it for null when the button
is pressed and then display an error if the control is not filled in? In that case
you don't even need the AfterUpdate code. Just test the control for null when the
button is pressed and then run the rest of your routine if an entry was made.


OK an UNBOUND CONTROL, UNBOUND TEXTBOX, I think you get
the picture....! Did not get the terminology
right...Does not work, ok let me explain what does not
work mean, this code does not work....

Private Sub txtBOMAdjValue_AfterUpdate()
If Not IsNull(Me.txtBOMAdjValue) Then
intBOMAdjVal = Me.txtBOMAdjValue
End If
End Sub

The user must type a value in this UNBOUND CONTROL!!!
txtBOMAdjValue, intBOMAdjVal is a global variable and
declared as such in a module.

Then i created a command button that does this
calculation.

Private Sub cmdCalculateTotals_Click()

If IsNull(sngBOMTotl = DSum("[Total
Cost]", "qryBOMSummary", "[RFQID] = " & [Forms]!
[frmRFQSummary]![RFQID])) Then
MsgBox "No Values to Calculate for BOM!"
Else
sngBOMTotl = DSum("[Total
Cost]", "qryBOMSummary", "[RFQID] = " & [Forms]!
[frmRFQSummary]![RFQID])
sngBOMTotl = Round(sngBOMTotl, 4)
Form_frmRFQSummary.Refresh
End If

If Not IsNull(intBOMAdjVal) Then
***Me.txtBOMTotal = sngBOMTotl + intBOMAdjVal****
Me.txtBOMTotal = Round(sngBOMTotl, 4)
Form_frmRFQSummary.Refresh
End If

End Sub

The code with the * does not work because Access does not
see this intBOMAdjVal variable because the value is
coming from the UNBOUND CONTROL....HELP! Is there anyone
that has a real answer???????
-----Original Message-----
I assume you mean an unbound control as there is no
such
thing as an unbound field.
What does "does not work" mean? Do you get an error? The syntax provided should
work as long as the control does not have an
expression
as its ControlSource.
I already tried this that does not work. IT IS and
UNBOUND FIELD!
-----Original Message-----
me!fieldname=variablename

Hope this helps!

Kevin
-----Original Message-----
how do assign a variable to an unbound field?
.

.



.


.
 
If you look at the code you posted below you are not assigning the value of a
variable to a TextBox. You are assigning the value of the TextBox to the variable.
Which "direction" are you actually wanting to go here? Assuming that the TextBox is
not Null both of the following will work...

SomeVariable = Me!SomeTextBox

Me!SomeTextBox = SomeVariable

The only thing I can think of that would prevent either of these from working is if
the variable is out of scope or the name of the TextBox is spelled wrong. The second
line would require that the TextBox have NO ControlSource or have a ControlSource
that is the name of a field in the underlying RecordSet and that RecordSet would have
to be editable. If the TextBox had a ControlSource that was an expression, it would
raise an error.




Christina Gonzalez said:
If Not is Null is NOT the ISSUE...ok, my issue is
assigning a variable to an unbound textbox... I need this
if not is null variable for good reason...which i don't
wish to explain at this time. I understand your
point...however my issue is assigning a variable to an
unbound textbox...
OK an UNBOUND CONTROL, UNBOUND TEXTBOX, I think you get
the picture....! Did not get the terminology
right...Does not work, ok let me explain what does not
work mean, this code does not work....

Private Sub txtBOMAdjValue_AfterUpdate()
If Not IsNull(Me.txtBOMAdjValue) Then
intBOMAdjVal = Me.txtBOMAdjValue
End If
End Sub

The user must type a value in this UNBOUND CONTROL!!!
txtBOMAdjValue, intBOMAdjVal is a global variable and
declared as such in a module.

Then i created a command button that does this
calculation.

Private Sub cmdCalculateTotals_Click()

If IsNull(sngBOMTotl = DSum("[Total
Cost]", "qryBOMSummary", "[RFQID] = " & [Forms]!
[frmRFQSummary]![RFQID])) Then
MsgBox "No Values to Calculate for BOM!"
Else
sngBOMTotl = DSum("[Total
Cost]", "qryBOMSummary", "[RFQID] = " & [Forms]!
[frmRFQSummary]![RFQID])
sngBOMTotl = Round(sngBOMTotl, 4)
Form_frmRFQSummary.Refresh
End If

If Not IsNull(intBOMAdjVal) Then
***Me.txtBOMTotal = sngBOMTotl + intBOMAdjVal****
Me.txtBOMTotal = Round(sngBOMTotl, 4)
Form_frmRFQSummary.Refresh
End If

End Sub

The code with the * does not work because Access does not
see this intBOMAdjVal variable because the value is
coming from the UNBOUND CONTROL....HELP! Is there anyone
that has a real answer???????

-----Original Message-----
I assume you mean an unbound control as there is no such
thing as an unbound field.

What does "does not work" mean? Do you get an error?
The syntax provided should
work as long as the control does not have an expression
as its ControlSource.

message
I already tried this that does not work. IT IS and
UNBOUND FIELD!
-----Original Message-----
me!fieldname=variablename

Hope this helps!

Kevin
-----Original Message-----
how do assign a variable to an unbound field?
.

.



.


.
 
Back
Top