Passing a value Not In List to input form

R

Rob P

Hi

I am using the follwing code extracted from an MS access book to pass a name
not in a combo list to an input form. Ie the the not in list procedure
saves the string OpenArgs opens and passes the string to the input form.

It basically works (having commented out one line) however the IsNothing
function does not appear to exsist? Have tried IsNull etc hence opening
the form normally generates an error message as the OpenArgs does not exsist

Any thougths much appricated



Private Sub Form_Load()
Dim strIName As String, intSpace As Integer

'If IsNothing(Me!OpenArgs) Then Exit Sub

'Parse the first and last names set default values for new record

strIName = OpenArgs

intSpace = InStr(strIName, " ")
Me![First Name].DefaultValue = """" & Left(strIName, intSpace - 1) & """"
Me![Last Name].DefaultValue = """" & Mid(strIName, intSpace + 1) & """"

End Sub
 
A

Allen Browne

OpenArgs could be Null or a zero-length string.

Try:
If Len(Nz(OpenArgs, vbNullString)) = 0 Then Exit Sub
 
D

Douglas J Steele

I believe OpenArgs is always defined, even if nothing is passed.

Try

If Len(Me!OpenArgs) = 0 Then Exit Sub
 
D

Douglas J Steele

Just realized I was incorrect: OpenArgs will be Null if it's undefined.

If Len(Me!OpenArgs & vbNullString) = 0 Then Exit Sub

However, are you hoping to prevent the form from opening, or are you just
trying to initialize the default values? If the former, it isn't going to
work...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Douglas J Steele said:
I believe OpenArgs is always defined, even if nothing is passed.

Try

If Len(Me!OpenArgs) = 0 Then Exit Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Rob P said:
Hi

I am using the follwing code extracted from an MS access book to pass a name
not in a combo list to an input form. Ie the the not in list procedure
saves the string OpenArgs opens and passes the string to the input form.

It basically works (having commented out one line) however the IsNothing
function does not appear to exsist? Have tried IsNull etc hence opening
the form normally generates an error message as the OpenArgs does not exsist

Any thougths much appricated



Private Sub Form_Load()
Dim strIName As String, intSpace As Integer

'If IsNothing(Me!OpenArgs) Then Exit Sub

'Parse the first and last names set default values for new record

strIName = OpenArgs

intSpace = InStr(strIName, " ")
Me![First Name].DefaultValue = """" & Left(strIName, intSpace - 1) & """"
Me![Last Name].DefaultValue = """" & Mid(strIName, intSpace + 1) & """"

End Sub
 
R

Rob P

Thanks to you both the expression from Allen
If Len(Nz(OpenArgs, vbNullString)) = 0 Then Exit Sub

work perfectly, similar to one below

I wanted to open the form from the "switchboard" and via the Not In List.
The former caused the error

many thanks



--
Robert P
Douglas J Steele said:
Just realized I was incorrect: OpenArgs will be Null if it's undefined.

If Len(Me!OpenArgs & vbNullString) = 0 Then Exit Sub

However, are you hoping to prevent the form from opening, or are you just
trying to initialize the default values? If the former, it isn't going to
work...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Douglas J Steele said:
I believe OpenArgs is always defined, even if nothing is passed.

Try

If Len(Me!OpenArgs) = 0 Then Exit Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Rob P said:
Hi

I am using the follwing code extracted from an MS access book to pass a name
not in a combo list to an input form. Ie the the not in list procedure
saves the string OpenArgs opens and passes the string to the input form.

It basically works (having commented out one line) however the
IsNothing
function does not appear to exsist? Have tried IsNull etc hence opening
the form normally generates an error message as the OpenArgs does not exsist

Any thougths much appricated



Private Sub Form_Load()
Dim strIName As String, intSpace As Integer

'If IsNothing(Me!OpenArgs) Then Exit Sub

'Parse the first and last names set default values for new record

strIName = OpenArgs

intSpace = InStr(strIName, " ")
Me![First Name].DefaultValue = """" & Left(strIName, intSpace - 1) & """"
Me![Last Name].DefaultValue = """" & Mid(strIName, intSpace + 1) & """"

End Sub
 

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