Find Record

leecsone

Registered User.
Local time
Today, 16:38
Joined
May 22, 2003
Messages
25
HI

I have a form that I use to find names. I have a preview report button on the form. Once I find the name how can I get the report to show the name I found. Say If I find the name Eddy brooks I press the preview report button and their is the name.


Thank you

leecsone
leecs@northrock.bm
 
Text box lookup

HI Pat

I saw an answer to a problem that jiocke had to lookup a specific record. I am haveing the same. Here is the code below can you please show me the correct way to wright this.



Private Sub Command17_Click()
On Error GoTo Err_Command17_Click

Dim stLinkCriteria
Dim stDocName As String

stDocName = "Access Form"
stLinkCriteria = "[LastName] = " & Chr(034) &
Me.txtSearchName & Chr(034) & " OR [NT username] = " &
Chr (34) & Me.txtNT username& Chr(34)

Exit_Command17_Click:
Exit Sub

Err_Command17_Click:
MsgBox Err.Description
Resume Exit_Command17_Click

End Sub


Thank you

leecsone


leecs@northrock.bm
 
Code:
Private Sub Command17_Click() 
On Error GoTo Err_Command17_Click 

Dim stLinkCriteria 
Dim stDocName As String 

stDocName = "Access Form" 
stLinkCriteria = "[LastName] = " & Chr(034) & 
Me.txtSearchName & Chr(034) & " OR [NT username] = " & 
Chr (34) & Me.txtNT username& Chr(34) 

[COLOR=blue]Docmd.openform stDocName,,,stLinkCriteria[/COLOR]

add the bit in blue to your code
 
Text,a number

HI Fizzio

The Line of code below shows up in red. I tried useing ( =,") to corect the problem but nothing I do works. Can you help me with this.

Chr (34) & Me.txtNT username& Chr(34)

Thank You

leecsone

Leecs@northrock.bm
 
Lots of typos in that single line:
1. space between first chr and (
2. no square breckets around the control name - they are required because embedded spaces are NOT allowed by VBA.
3. no space between the e and the &
4. Also, if a statement is continued on the next line, you need to add the continuation character to the end of the previous line.

Chr(034) & Me.[txtNT username] & Chr(034)

BTW, if the square brackets don't fix the problem with the bad field name, VBA may have replaced the offending space with an underscore so try that. Next time, DO NOT USE EMBEDDED SPACES in your object names. NO programming language will allow them and VBA is no exception.
 

Users who are viewing this thread

Back
Top Bottom