?
Solved

Run-time error '3464'

Posted on 2009-04-06
4
Medium Priority
?
669 Views
Last Modified: 2013-11-05
In the attached example, form MasterBrokerAcct, "Edit" button is supposed to open another form, but it doesn't work. The sample is from Access Inside Out book. It runs fine there. Can't figure out why...
Thanks
OHTS5.mdb
0
Comment
Question by:lysenko
  • 2
4 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1200 total points
ID: 24079680


change this line

    strWhere = "[AcctNumber] IN (" & strWhere & ")"


to

    strWhere = "[AcctNumber] IN ('" & strWhere & "')"
0
 

Author Comment

by:lysenko
ID: 24079764
thanks a lot. it works. why does missing a single quote cause this problem?
0
 
LVL 28

Accepted Solution

by:
TextReport earned 800 total points
ID: 24079811
The problem is that the field you are using is a string and therefore you need the ' or " around the values. As you have the code written to use the multiselect listbox you therefore need to fix the line

        strWhere = strWhere & Me!lstBrokerAcct.Column(0, varItem) & ","

so it reads as

        strWhere = strWhere & Chr(39) & Me!lstBrokerAcct.Column(0, varItem) & Chr(39) & ","

Cheers, Andrew
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1200 total points
ID: 24079848
because the AcctNumber field is a Text type of data

actually this is the codes that you need to use, the first one above will fail if you choose more than one item from the listbox


Private Sub cmdSome_Click()
Dim strWhere As String, varItem As Variant
    ' Request to edit items selected in the list box
    ' If no items selected, then nothing to do
    If Me!lstBrokerAcct.ItemsSelected.Count = 0 Then Exit Sub
    ' Loop through the items selected collection
    For Each varItem In Me!lstBrokerAcct.ItemsSelected
        ' Grab the CompanyID column for each selected item

'*** this line was changed *****
        strWhere = strWhere & Chr(39) & Me!lstBrokerAcct.Column(0, varItem) & Chr(39) & ","
    Next varItem
    ' Throw away the extra comma on the "IN" string
    strWhere = Left$(strWhere, Len(strWhere) - 1)
    ' Open the invoices form filtered on the selected invoices
    strWhere = "[AcctNumber] IN (" & strWhere & ")"
    DoCmd.OpenForm FormName:="frmBrokerAcctEdit", wherecondition:=strWhere
    ' Put the focus on the form
    Forms!frmBrokerAcctEdit.SetFocus
    DoCmd.Close acForm, Me.Name
End Sub
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question