Solved

Problem with split form

Posted on 2013-06-08
4
472 Views
Last Modified: 2013-06-09
I have a split form with the datasheet on the right.  In the left column I have an unbound field.  When the user enters a string of characters in the unbound field and then clicks a command button at the bottom of the left column I want any records that have that typed string of characters in any field to display in the rows in the datasheet.

What would the onclick code be for the command button?

Also, when the form opens no records display which is fine but I can't figure out why they aren't displaying.  The form has a table as its recordsource. I have Data Entry set to No.
0
Comment
Question by:SteveL13
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
als315 earned 250 total points
ID: 39232530
You can try to use filters:
http://allenbrowne.com/ser-28.html

May be you can upload sample DB?
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 39232563
Here is one way of doing it:

assuming you want to search in the following Table fields:
fName
address
phone1
phone2

assuming your Form is Form1, your search field is Search1,

make a query, add your table, add all the fields you want, then
add a field like this:
my_Fields: [fName] & " " & [address] & " " & [phone1] & " " & [phone2]
in the criteria write this:
Like "*" & Forms!Form1!Search1 & "*"

now make the datasheet form's Record Source, the above query.
after you enter the search criteria, your command button should contain the following command:
me.requery
this will bring all the Records that contain your search :)

as for No data show, make sure the Filter of the Form is empty too, and you might want to make FilterOn=NO

jaffer
0
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 250 total points
ID: 39232845
1.  You simply need to set the Forms Filter property and turn it on.

Private sub cmd_Filter_Click

     me.Filter = "[field1] & [Field2] & [Field3] Like '*" & me.txtSearch & "*'"
     me.FilterOn = True

End Sub

2.  Not entirely sure why the form comes up with no records displayed.  Check the FilterOnOpen property and set it to No.
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 39233112
Hi  SteveL13

if you use fyed's solution, make sure you leave a space between the fields, like I did, like this:
so instead of
me.Filter = "[field1] & [Field2] & [Field3] Like '*" & me.txtSearch & "*'"

do it like this:
me.Filter = "[field1] & chr(32) & [Field2] &  chr(32) & [Field3] Like '*" & me.txtSearch & "*'"

the reason is:
assuming:
filed1= 1234
field2= 5678
field3= 90ab

and if you search for "3456":
based on  fyed's solution, your search will be in:
1234567890ab
here your search WILL find a match, and it will show you the Record/s, which is wrong,

but when you add a space between the fields, then your search will be in:
1234 5678 90ab
and obviously, you will NOT find a match :)

something to keep in mind :)

jaffer

ps: chr(32) means sapce
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question