Solved

Run-time error '3464'

Posted on 2009-04-06
4
655 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 300 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 200 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 300 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

912 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now