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 January 30th, 2006, 08:05 AM
Registered User
 
Join Date: Jan 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default User interaction...

Hi everyone,
New to this forum (and VBA ) - but amazed by the amount of information it contains.

One thing I do miss though is topics about user-friendly interfaces...
OK - I know, a world without users etc etc :D but still... What's the point of having a database if no one uses it???

To me, the most important is to find the data I've stored in my DB, and I'm struckling with something as simple as a string search - and it drives me crazy :(

I'm running Access 2003 on XP pro.
Having a plain table with usernames etc as source, a form where I can see the information and all I ask for is a routine, that gives me a window with a line where I can write a name (o part of it) and then the form returns with that specific record.

From my form I double-click on the field [Nombre] and I call following Sub:

Public Sub BuscaUsuario()

Dim Dbs As Database
Dim Rst As DAO.Recordset
Dim BuscaString As String
Dim BNombre1 As String

BuscaString = ""
BuscaString = InputBox("You are looking for...?")

Set Dbs = CurrentDb
BNombre1 = "[Nombre]=" &BuscaString
Set Rst = Me.RecordsetClone
Rst.MoveFirst
If Rst.NoMatch Then
   MsgBox "No match!"
Else
   Me.Bookmark = Rst.Bookmark
End if
Rst.FindFirst (BNombre1)
Mr.Requery

Rst.Close
Dbs.Close

End Sub

I'm using the InBox because that's the only "Pop-Up" function I know in VBA.
I've tried to enter the SQL directly in the Properties for the form, also with a string variable, and very elegant pops-up a window in order to enter a value in the variable - but I can't make it works with VBA
Instead of = I'd like to use LIKE as users rarely know the whole name and sir-name of the person they are looking for.

Anyone here who can say the magic syntax I'm missing? :D

Txs for a great place to find info...
Don Herman


 
Old January 30th, 2006, 05:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

¡Bienvenidos a P2P, Don Herman!

Have you tried...?

BNombre1 = "[Nombre] = '" &BuscaString & "'"

Why? Because BuscaString is a string. They way you have it now, Access is expecting a number.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old January 31st, 2006, 12:06 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Default

¡ Y otro Bienvenidos!

To use LIKE:

BNombre1 = "((table.[Nombre]) LIKE " & "'" & BuscaString & "*'" & ")"

Access uses * as wildcard.

HTH,
Loralee


 
Old January 31st, 2006, 08:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Oh, if you want to do a search within the string then might as well use the asterisks on BOTH sides...

BNombre1 = "[Nombre] Like '*" &BuscaString & "*'"


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel/Access interaction SarahDC Access VBA 0 September 24th, 2008 01:41 PM
.dll interaction with an application DavidStowell Visual Basic 2008 Essentials 2 March 3rd, 2008 04:33 PM
Calling javascript without user interaction bcahillane XSLT 1 November 3rd, 2006 12:24 PM
Reagrding the mouse interaction in C# CsharpHelp C# 5 May 19th, 2005 03:58 PM
INTERACTION anil_soma ADO.NET 2 September 23rd, 2004 01:58 AM





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