Problem with form opening From List Box

K

kc-mass

Hi,

I have a form with a list box that lets me assign companies to employees.
Some employees get a full assignment (100% of value derived) and some get a
partial(55%, etc). When the user double clicks on the assignment in the
list box a form pops up showing the company name and the percentage (which
defaults to 100%). The user can then edit the percentage. The code which is
supposed to manipulate the popped up form is failing throwing an error on
each reference to it of "Method of Object 'Forms' failed". I commented out
each in tern and it fails on all the references. The code is below as is the
SQL it produces.

Ideas - Suggestions?

Thx

Kevin

Private Sub lstAssignments_DblClick(Cancel As Integer)
Dim varItem As Variant
Dim lngCustID As Long
Dim lngEmplID As Long
Dim strSQL As String
Dim strCriteria As String
If Me.lstAssignments.ItemsSelected.Count = 0 Then
MsgBox ("You need to select an assignment first.")
Exit Sub
End If
With Me!lstAssignments
For Each varItem In .ItemsSelected
lngCustID = .Column(2, varItem)
lngEmplID = .Column(0, varItem)
strCriteria = "tblCustomers.CustomerID = " & lngCustID & " And
EmployeeID = " & lngEmplID & " AND Not ISNULL(EndDate) "
Next varItem
End With
strSQL = "SELECT tblCustomers.CustomerName,
tblAssignments.PercentRevenue " _
& "FROM tblAssignments INNER JOIN tblCustomers " _
& "ON tblAssignments.CustomerID = tblCustomers.CustomerID " _
& "WHERE " & strCriteria & ";"
Debug.Print strSQL
DoCmd.OpenForm "frmPopPercentCommission"
'Forms!frmPopPercentCommission.Visible = False
'Forms!frmPopPercentCommission.[Record Source] = strSQL
'Forms!frmPopPercentCommission.Requery
Forms!frmPopPercentCommission.Visible = True
End Sub


SELECT tblCustomers.CustomerName, tblAssignments.PercentRevenue FROM
tblAssignments INNER JOIN tblCustomers ON tblAssignments.CustomerID =
tblCustomers.CustomerID WHERE tblCustomers.CustomerID = 1672 And EmployeeID
= 92571 AND Not ISNULL(EndDate) ;
 
K

kc-mass

I solved the "Method of Object Problem - bad reference to Form et al.

The problem now (I Think) is that the Record source is not being updated
with the SQL
and is thus returning the wrong customer. I will alter the code below for
the form references.

Any help with the recordsource appreciated.

Thanks

Kevin

kc-mass said:
Hi,

I have a form with a list box that lets me assign companies to employees.
Some employees get a full assignment (100% of value derived) and some get
a partial(55%, etc). When the user double clicks on the assignment in the
list box a form pops up showing the company name and the percentage (which
defaults to 100%). The user can then edit the percentage. The code which
is supposed to manipulate the popped up form is failing throwing an error
on each reference to it of "Method of Object 'Forms' failed". I commented
out each in tern and it fails on all the references. The code is below as
is the SQL it produces.

Ideas - Suggestions?

Thx

Kevin

Private Sub lstAssignments_DblClick(Cancel As Integer)
Dim varItem As Variant
Dim lngCustID As Long
Dim lngEmplID As Long
Dim strSQL As String
Dim strCriteria As String
If Me.lstAssignments.ItemsSelected.Count = 0 Then
MsgBox ("You need to select an assignment first.")
Exit Sub
End If
With Me!lstAssignments
For Each varItem In .ItemsSelected
lngCustID = .Column(2, varItem)
lngEmplID = .Column(0, varItem)
strCriteria = "tblCustomers.CustomerID = " & lngCustID & " And
EmployeeID = " & lngEmplID & " AND Not ISNULL(EndDate) "
Next varItem
End With
strSQL = "SELECT tblCustomers.CustomerName,
tblAssignments.PercentRevenue " _
& "FROM tblAssignments INNER JOIN tblCustomers " _
& "ON tblAssignments.CustomerID = tblCustomers.CustomerID " _
& "WHERE " & strCriteria & ";"
Debug.Print strSQL
DoCmd.OpenForm "frmPopPercentCommission"
Me.RecordSource = strSQL
Me.Requery
End Sub
 
T

tom_willpa

high quality Soccer jerseys NBA Jersey tracksuit and jackets, GHD
hairstraightener supplier from www.willpa.com

Are you a Retail businessman who bother by the purchase price? China
Cheapest TOP wholesale website can help you

we are specialize in replica sport goods manufacturing in china, we can
offer you all kinds of soccer jersey, NBA jersey,shoes and so on. they are
the best brand replica goods whih are look the same as the original goods.
excellent quality and steady supply for them. we have been marketed in Europe
and American for 3 year. all the goods we offer are AAA quality. our soccer
jersey are Thailand style. If any goods you buy from my company have problem,
we will refund or resend them again. Most of ourProducts have no minimum
order requirements,soyou can shop retail goods at wholesale prices. if you
can buy more than 300usd. We offer free shipping. The more you buy the more
discount for you.

National soccer jerseys: http://www.willpa.com
Club soccer jerseys: http://www.willpa.com
NBA Jerseys: http://www.willpa.com
T-shirt and shirt: http://www.willpa.com
Tracksuit: http://www.willpa.com
Hoody & Jackets: http://www.willpa.com
UGG boots: http://www.willpa.com
Hair style: http://www.willpa.com
shopping Index: http://www.willpa.com

EMS shipping. 7days arrive, paypal accept

want more information pls contact us or check our website: www.willpa.com
 

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