ATTN: Phobos - Search -

ATTN: Phobos - Search -

Post by Bill » Tue, 23 Sep 2003 06:17:04


his is a multi-part message in MIME format.


I create "Find" Button on the form and use to look for the file number for
1-2-3
1-23
123

I use the form link to the table instead of Query. Is there a way for me to
use the button to look for anything 1-2-3 or 1-23 or 123 to pull up the file.

Recently, you give the code and it works for queries. I am trying to find a
way to use Table just like you give me the code. When I click the button
and pop up to look for the file number. I want to input either 1-2-3 or 1-23 or 123
to pull the file.

Your help would be great.

********************************************************

Hi Bill,

I'm not sure what you are trying to do, could you be a bit more specific?

P

"Bill" < XXXX@XXXXX.COM > wrote in message
news:nIhbb.9069$ XXXX@XXXXX.COM ...
Hi Phobos,

Thanks, it works. I m really appreciated your help.

I have a question if that is possible to use your code into Find Button from
the form to look RecordNumber either Table or Query. I copy the code "Find
button" if you can help me to insert your code "Begin to End" into the code
of "Find Button".

********** Find Button *******************
Private Sub cmdFind_Click()
On Error GoTo Err_cmdFind_Click

Me.Filter = ""
Me.FilterOn = False
'Screen.PreviousControl.SetFocus
Me.RecordNo.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_cmdFind_Click:
Exit Sub
Err_cmdFind_Click:
MsgBox Err.Description
Resume Exit_cmdFind_Click
End Sub
****************************************************************************
***********

'Code Begins
Function replace(fld As String, find As String, Optional repwith As String =
"") As String
Dim fldLen As Long
fldLen = Len(fld)

Dim findLen As Long
findLen = Len(find)

Dim newFld As String
newFld = ""

Dim x As Long
For x = 1 To fldLen
If Mid(fld, x, findLen) = find Then
newFld = newFld & repwith
x = x + findLen - 1
Else
newFld = newFld + Mid(fld, x, 1)
End If
Next

replace = newFld
End Function
'Code ends

In your query, one of the fields should be:

replace([fieldName],"-")

This removes hyphens (the default for the repWith argument is a
zero-length-string).

P

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1226" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I create "Find" Button on the form and use to look
for the file number for</FONT></DIV>
<DIV><FONT face=Arial size=2>1-2-3</FONT></DIV>
<DIV><FONT face=Arial size=2>1-23</FONT></DIV>
<DIV><FONT face=Arial size=2>123</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I use the form link to the table instead of
Query.   Is there a way for me to </FONT></DIV>
<DIV><FONT face=Arial size=2>use the button to look for anything 1-2-3 or 1-23
or 123 to pull up the file.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<D