A
Anthony
Hi
I have two functions (behind command buttons) called FunctionName1 and
FunctionName2 and I want to parse a value from FunctionName1 and a value
from FunctonName2 to another function called "CombinedFieldFunction". The
code below only passes the last value selected but never both at the same
time. How can I amend the following code so that the third functions accepts
both variables from the other two functions.
***************************************
Public Function FunctionName1()
Dim debstr As String
Forms![FormName]![FieldA] = "ContentsFieldA"
debstr = "ANewValue"
CombinedFieldFunction (debstr)
End Function
**********************************
Public Function FunctionName2()
partstr As String
Forms![FormName]![FieldB] = "ContentsFieldB"
partstr = "AnotherValue"
CombinedFieldFunction (partstr)
End Function
************************************
Public Function CombinedFieldFunction(Optional debstr As String, _
Optional partstr As String)
Dim total As String
If debstr <> "" Then
total = debstr & " " & partstr
Else
total = partstr
End If
Forms![FormName]![FieldE] = total
End Function
*********************************
Some more info about what I'm trying to do...
I have a form which contains a number of fields (ie A, B, C and D) which are
populated by clicking on buttons. If values are entered in one or more of
these fields, I want another field (ie E) to automatically contain
'combined' values. These values are not a simple concatenation of the values
entered in fields A, B, C or D, but they are related. For example, I want
the value in field E to be "ANewValue" if the value selected in field A is
"ContentsFieldA" as shown in "FunctionName1". If "ContentsFieldA" is
selected in field A and "ContentsFieldB" is selected in field B, I want the
value in field E to be "ANewValue AnotherValue".
Please tell me where the problem is
Thanks
Anthony
I have two functions (behind command buttons) called FunctionName1 and
FunctionName2 and I want to parse a value from FunctionName1 and a value
from FunctonName2 to another function called "CombinedFieldFunction". The
code below only passes the last value selected but never both at the same
time. How can I amend the following code so that the third functions accepts
both variables from the other two functions.
***************************************
Public Function FunctionName1()
Dim debstr As String
Forms![FormName]![FieldA] = "ContentsFieldA"
debstr = "ANewValue"
CombinedFieldFunction (debstr)
End Function
**********************************
Public Function FunctionName2()
partstr As String
Forms![FormName]![FieldB] = "ContentsFieldB"
partstr = "AnotherValue"
CombinedFieldFunction (partstr)
End Function
************************************
Public Function CombinedFieldFunction(Optional debstr As String, _
Optional partstr As String)
Dim total As String
If debstr <> "" Then
total = debstr & " " & partstr
Else
total = partstr
End If
Forms![FormName]![FieldE] = total
End Function
*********************************
Some more info about what I'm trying to do...
I have a form which contains a number of fields (ie A, B, C and D) which are
populated by clicking on buttons. If values are entered in one or more of
these fields, I want another field (ie E) to automatically contain
'combined' values. These values are not a simple concatenation of the values
entered in fields A, B, C or D, but they are related. For example, I want
the value in field E to be "ANewValue" if the value selected in field A is
"ContentsFieldA" as shown in "FunctionName1". If "ContentsFieldA" is
selected in field A and "ContentsFieldB" is selected in field B, I want the
value in field E to be "ANewValue AnotherValue".
Please tell me where the problem is
Thanks
Anthony