S
shadowsong
I have two combo boxes that get their rowsources via a select query on
enter. currently, the first one gives company names, and the second
one gives salesperson names for whichever company was selected.
I would like the second one to populate with all salesperson names if
company is blank on enter, and set company name to the one associated
with the selected salesperson, if company name is blank on exit.
Here's what I tried:
Private Sub SALESNAME_Enter()
If Forms![SALESPERSON OUTPUT]![DLRNUM].Value Is Not Null _
Then Forms![SALESPERSON OUTPUT]![SALESNAME].RowSource = _
"SELECT DISTINCT [DATA].[SALESNAME] FROM DATA WHERE [DATA].[DLRNUM]
= FORMS![SALESPERSON OUTPUT]![DLRNUM]" _
Else Forms![SALESPERSON OUTPUT]![SALESNAME].RowSource = _
"SELECT DISTINCT [DATA].[SALESNAME] FROM DATA"
End Sub
Private Sub SALESNAME_Exit(Cancel As Integer)
If Forms![SALESPERSON OUTPUT]![DLRNUM] Is Null _
And Forms![SALESPERSON OUTPUT]![SALESNAME] Is Not Null _
Then Forms![SALESPERSON OUTPUT]![DLRNUM].Value = _
"SELECT DISTINCT [DATA].[DLRNUM] FROM DATA WHERE [DATA].[SALESNAME]
= Forms![SALESPERSON OUTPUT]![SALESNAME]"
End Sub
It gives me an "object required" runtime error and highlights from
"if" to "then", for whichever sub i trigger. Which object is it
talking about? Did I forget to define something?
enter. currently, the first one gives company names, and the second
one gives salesperson names for whichever company was selected.
I would like the second one to populate with all salesperson names if
company is blank on enter, and set company name to the one associated
with the selected salesperson, if company name is blank on exit.
Here's what I tried:
Private Sub SALESNAME_Enter()
If Forms![SALESPERSON OUTPUT]![DLRNUM].Value Is Not Null _
Then Forms![SALESPERSON OUTPUT]![SALESNAME].RowSource = _
"SELECT DISTINCT [DATA].[SALESNAME] FROM DATA WHERE [DATA].[DLRNUM]
= FORMS![SALESPERSON OUTPUT]![DLRNUM]" _
Else Forms![SALESPERSON OUTPUT]![SALESNAME].RowSource = _
"SELECT DISTINCT [DATA].[SALESNAME] FROM DATA"
End Sub
Private Sub SALESNAME_Exit(Cancel As Integer)
If Forms![SALESPERSON OUTPUT]![DLRNUM] Is Null _
And Forms![SALESPERSON OUTPUT]![SALESNAME] Is Not Null _
Then Forms![SALESPERSON OUTPUT]![DLRNUM].Value = _
"SELECT DISTINCT [DATA].[DLRNUM] FROM DATA WHERE [DATA].[SALESNAME]
= Forms![SALESPERSON OUTPUT]![SALESNAME]"
End Sub
It gives me an "object required" runtime error and highlights from
"if" to "then", for whichever sub i trigger. Which object is it
talking about? Did I forget to define something?