In FormA, I have a button that opens FormB with OpenArgs. In FormB, the OpenArgs are translated into default values for certain controls.
FormB is a continuous form. For this reason, I can't assign .Value -- it has to be .DefaultValue. Otherwise it changes the values in the first record in the form.
If any of the transferred controls in FormA has no data, then there's of course no data in the corresponding default value in FormB. Apparently Access is reading this as a 'zero-length string' in FormB, and it gives me an error message (Field tbl.fld cannot be a zero-length string) when I try to save the new record in FormB.
How do I get it to read Null values in FormA as Null in FormB? I haven't been able to figure it out.
Here's my code:
In FormA:
Expand|Select|Wrap|Line Numbers
- Private Sub cmdButton_Click()
- Dim stDocName As String
- Dim stLinkCriteria As String
- stDocName = "Add Job"
- DoCmd.OpenForm stDocName, , , stLinkCriteria, , , OpenArgs:=txtInfo1 & "|" & txtInfo2 & _
- "|" & txtInfo3
- End Sub
Expand|Select|Wrap|Line Numbers
- Public Function ParseText(TextIn As String, x) As Variant
- On Error Resume Next
- Dim Var As Variant
- Var = Split(TextIn, "|", -1)
- ParseText = Var(x)
- End Function
Expand|Select|Wrap|Line Numbers
- Private Sub Form_Load()
- If Not IsNull(Me.OpenArgs) Then
- Dim strText1 As String
- Dim strText2 As String
- Dim strText3 As String
- strText1 = ParseText(OpenArgs, 0)
- strText2 = ParseText(OpenArgs, 1)
- strText3 = ParseText(OpenArgs, 2)
- Me.txtFirst.DefaultValue = "=" & """" & strText1 & """"
- Me.txtSecond.DefaultValue = "=" & """" & strText2 & """"
- Me.txtThird.DefaultValue = "=" & """" & strText3 & """"
- End If
- End Sub
Angi