Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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 August 17th, 2005, 03:51 AM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Searhing Records problems

Dear All,

I encounter some problems in searching.

First, i have create a edit form which have 5 fileds and contain a button search. User can click on the search button to check the fields they entered is in the personal details form or not.
PS. In the personal details form which contain a subform of cert details.

After they enter the field in edit form , the problems happened. I don't know why the field which is in the subform that i needed to enter one more time in order to get in the personal details form but it shows all the records.

Can anyone tell me what can i do??

Here is the code of edit form
Option Compare Database
Dim t

Private Sub Find_Click()
Dim db As DAO.Database, rcd As DAO.Recordset
Dim count As Integer

gstrwherebook = ""
t = ""
count = 0

'in the main form of personal detail
If Not IsNull(Me!ID) Then
gstrwherebook = "[ID] like '" & Me!ID & "'"
End If

'in the subform of personal details
If Not IsNull(Me!CertNo) Then
If gstrwherebook = "" Then
gstrwherebook = "[cert no] like '" & Me!CertNo & "'"
Else
gstrwherebook = gstrwherebook & "AND [cert no] like '" & Me!CertNo & "'"
End If
End If

'in the subform of personal details
For Each varItm In Me![type].ItemsSelected
t = t & " or [type] Like '" & Me![type].ItemData(varItm) & "'"
count = count + 1
Next varItm
If t <> "" Then
t = Right(t, Len(t) - 4)
End If
If count <> 0 Then
If gstrwherebook = "" Then
gstrwherebook = gstrwherebook & t
Else
gstrwherebook = gstrwherebook & "AND " & gstrwherebook & t
End If
End If

'in the subform of personal details
If Not IsNull(Me!location) Then
If gstrwherebook = "" Then
gstrwherebook = "[location] like '" & Me!location & "'"
Else
gstrwherebook = gstrwherebook & "AND [location] like '" & Me!location & "'"
End If
End If

DoCmd.OpenForm "personal details", acNormal, , gstrwherebook
DoCmd.Close acForm, Me.Name
End Sub

The cod maybe worng because i'm the beginner to write vba and these book is just find out from books and i modify it!! So if you find it has problems, please tell me to correct it!! Thanks!!

Please help me, Thanks a lot!!!




Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in updating records & finding records naveed77 VB Databases Basics 1 January 16th, 2007 12:12 PM
problem in updating records & finding records naveed77 VB How-To 1 January 16th, 2007 12:10 PM
Edit records problems Indo77 Classic ASP Databases 0 August 11th, 2005 09:35 AM
validate.asp problems and logon.asp problems p2ptolu Classic ASP Databases 0 February 16th, 2005 02:34 PM
Problems With returning records through ADO marko_one Classic ASP Databases 5 September 30th, 2004 04:06 AM





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