Solved

Problem with split form

Posted on 2013-06-08
4
501 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

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 48

Assisted Solution

by:Dale Fye
Dale Fye 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

623 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