On Current Value List Expression Not Working

T

Tal

I have the following code in the OnCurrent event of my form.
It is returning nothing, though I do not get any error messages either, just
a very empty combo box.
Help much appreciated.
Cheers,
Tal


Private Sub Form_Current()
Dim strRowSource As String

If IsNull(Me.txtClientLastName) = False Then
strRowSource = strRowSource & Me.txtClientFirstName & " " &
Me.txtClientLastName & ";"
If IsNull(Me.txtClientCompanyOnly) = False Then
strRowSource = strRowSource & Me.txtClientCompanyOnly & ";"
If IsNull(Me.txtClientSpouseFirstName) = False Then
strRowSource = strRowSource & Me.txtClientSpouseFirstName & " " &
Me.txtClientLastName & ";"
strRowSource = strRowSource & Me.txtClientFirstName & " or " &
Me.txtClientSpouseFirstName & " " & Me.txtClientLastName & ";"
If IsNull(Me.txtClientSpouseLastName) = False Then
strRowSource = strRowSource & Me.txtClientSpouseFirstName & " " &
Me.txtClientSpouseLastName & ";"
End If

If Len(strRowSource) > 0 Then
strRowSource = Left$(strRowSource, Len(strRowSource) - 1)
Me.keyReceiptTo.RowSourceType = "Value List"
Me.keyReceiptTo.RowSource = strRowSource
Else
Me.keyReceiptTo.RowSourceType = ""
Me.keyReceiptTo.RowSource = ""
End If
End Sub
 
D

Damon Heron

well, you should be getting an error msg. Do you have Option Explicit at
the top of the form module? Anyway, you have no "End IF" after each if
statement.

Damon
 
D

Damon Heron

The Newsgroup formatting shows multiple lines. So if these if statements
are all on one line then you wouldnt need "end if".
Have you put a breakpoint on the current event and stepped thru? I tested
the code and it worked for me.

Damon
 
T

Tal

Perfect fantastic. You are a star!!!!!
I guess it was the Option Explicit thing cause I had already caught the End
If thing. What does Option Explicit mean anyway?
 
D

Damon Heron

Glad to help. Actually, the Option Explicit statement just catches
un-declared variable errors at compile time. If you don't use it, then any
variables are assigned a variant type, and no error msg appears. So I am
not sure how this helped you if you didn't have a undeclared variables!

Damon
 

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