Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 14th, 2005, 08:28 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Default Combo Box Error

Help Needed
I am using the following code to accomdate apostrophes in my combo box
Private Sub Combo8_Dirty(Cancel As Integer)
Dim srchreplace As String
Dim gfindstring As String
If (InStr(Combo8, "'")) Then
gfindstring = srchreplace(Combo8)
Else
gfindstring = Combo8
End If
End Sub
but when a person's name appears in the combo box with an apostrophes I am getting the following error message
Error no 3077 Description Syntax error (Missing operator)in expression

Brendan Bartley
__________________
Brendan Bartley
 
Old September 14th, 2005, 08:39 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hiya Brendan!

What is the combo box for? What's in the after update code? The problem is that if you're selecting a record for a form based on the combobox, the code that is automatically generated, won't work if the field has apostrophes.

Send me the code and I'll show you how to fix it.

Kevin

dartcoach
 
Old September 14th, 2005, 08:45 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the code is as follows
Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[OFFICE] = '" & Me![Combo8] & "'"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    Thanks
Brendan


Brendan Bartley
 
Old September 14th, 2005, 08:48 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Brendan,

Try this:

rs.FindFirst "[OFFICE] = " & """" & Me![Combo8] & """"

Kevin

dartcoach
 
Old September 14th, 2005, 09:27 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Kevin working well so far

Brendan Bartley
 
Old September 14th, 2005, 09:34 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Glad to help Brendan.
Let me know if you need anything else.

Kevin

dartcoach





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Error 2118 from combo box requery darrenb Access VBA 1 January 8th, 2008 01:31 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
Combo Box / VBA Error socoolbrewster Access 2 March 19th, 2005 01:03 PM
Weird Combo Box Binding Error [email protected] Pro VB.NET 2002/2003 0 October 8th, 2003 08:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.