Hi guys i have a small problem passing a variable into a sql statement. Could i please get some assistance.
Here is my current code:
As the comment in case Dealer_Product_Group states I wish to do 2 things:Code:Private Sub Form_Open(Cancel As Integer) Dim dc As Variant Select Case Me.OpenArgs Case "Dealer_Totals" Me.Date_Combo.Visible = True Me.Distributor_Combo.Visible = False Me.Date_Combo.RowSource = "SELECT COMMISSION_MONTH FROM COMMISSION_MONTH WHERE (TRANSACTIONS_IMPORTED = 1)" Case "Dealer_Product_Group" '1st make Date_combo visible = false, until user first selects distributor, then make date_combo visible = true, and pass in distributor value into select statement below Me.Date_Combo.Visible = false Me.Distributor_Combo.Visible = True dc = Me.Distributor_Combo Me.Date_Combo.RowSource = "SELECT distinct COMMISSION_MONTH FROM commission_txn WHERE (payment_point = @dc)" Case "nilMajor_Movement" Me.Date_Combo.Visible = True Me.Distributor_Combo.Visible = False Me.Date_Combo.RowSource = "SELECT COMMISSION_MONTH FROM COMMISSION_MONTH WHERE (TRANSACTIONS_IMPORTED = 1)" End Select End Sub
1) make date_combo invisible, then visible once the user firstly selects a distributor in the distributor_combo box.
2) Once this is done i want to pass this value into the dc variable as defined in the sub. Is this the correct way to do it? the problem is in sql to pass a variable requires the @ symbol but i cant do this in VB i.e: cant do dim @dc as variant
The reason why i want to do this is because i want to limit the amount of dates the user inputs once a distributor has been chosen. (type of validation such that the user cant put in bogus dates based on a distributor)
Cheers
Champinco




Reply With Quote