473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

I need a VBA code for my unbound Search form.

Hi,

I have a search form, which is now unbound from my table, and by that I mean I have gone and set the form's Record Source to remain blank. I have also gone and set the Control Source of each text box and combo box to also remain blank.

I did this because when I would search for a record by a particular field, by Document Number for example, the data I typed into the text box, or selected in the combo box, would then be stored as a new record in my table, which I did not want.

So, by doing this my Search button no longer works.

Now, do I need to write a VBA code consisting of information that will let me search by each field? For instance, in my code do I need to include information that will let me search by the Document Number, and/or File Type, and/or Revision, and/or Project, and/or Manufacturer, and so forth?

I have been searching all day for example VBA codes for searching, but have not been successful.

Thank you for any input.
Nov 28 '11 #1
6 1680
NeoPa
32,556 Expert Mod 16PB
Your first steps are certainly correct ones.

Check out these articles for what is hopefully, all you need on the subject :
Example Filtering on a Form.
Cascaded Form Filtering.

NB. Although filtering is often associated with searching, the two terms are not exactly synonymous. Searching selects a record from within a larger group (recordset), whereas filtering restricts the group to include only those records which match the criteria. From the titles you'll see that both articles pertain directly to filtering, but it's not too much of a stretch from there to use the same concept as a search instead.

When you've been through the articles come back if you feel you need help with converting them to be specifically search related.
Nov 28 '11 #2
NeoPa,

Thank you. I have rethought my design and think the use of a filter would indeed be better. I would like for users to be able to search for only those records in which they specify based upon one or more fields. For instance, a user may want to search for only those records that are ".docx" files and "approved." Then, those records that meet the two criteria, for example, would populate a read-only table. My form is set to read-only, so I may not have to do anything there since I was thinking I would just change my single form to a split form and then the search results would populate the table on the same form. I have tried this, although the filter button I set up using the Command Button Wizard is not working.

At first it stated the records were locked, which they were, so I set that property to "No Records," but still no luck.

I used the filter by form tool on my table itself and do like how it works. At this point, I am not sure what needs to be done. Do I need to set up a filter on the table itself for the filter records button to work on my form? Or do I just need to write a code for the button to work on my form?

Any feedback is greatly appreciated.

Thank you.
Nov 29 '11 #3
Mihail
759 512MB
Take a look here:
http://bytes.com/topic/access/answer...te#post3688063

The thread is not finalized but maybe you can find anything useful.
Nov 29 '11 #4
Mihail,

I can't open the link for some reason. It keeps closing the program.

Thank you.
Nov 29 '11 #5
O.k. I did change my Default View in the Properties Pane to a Split Form. I also changed the Split Form Datasheet to Read-only in the Properties Pane as well. When I select the criteria (combo boxes) or type in the criteria (text boxes)for the fields I wish to filter by though, nothing happens.
Nov 29 '11 #6
NeoPa
32,556 Expert Mod 16PB
I'm somewhat confused as you're talking about populating a read-only table at one point. This is strange because :
  1. Read-only tables cannot be populated under any circumstances.
  2. Forms don't generally populate tables as such. They are able to maintain records in a table (and even add new ones), but populating a table is a term I would associate more with an APPEND query.

Aswgawlag:
Do I need to set up a filter on the table itself for the filter records button to work on my form? Or do I just need to write a code for the button to work on my form?
You certainly don't need to change the design of the table at all. The form only is changed, and that is temporary as this isn't saved into the design of the form.

Your questions seem to indicate that you haven't looked at, or maybe just understood very well, either of the articles I linked to in my earlier post. I strongly recommend that you download the attachments and play with them. Just play around and see how they work. I'm sure having done so you will appreciate the whole subject so much more easily.
Nov 29 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: misschristalee | last post by:
I'm having a brain blockage day.... Scenario: Search Form with 6 text boxes Query has same six fields Each has this IIF: IIf(IsNull(!!),"",!!) with each dictating the correct text box of...
2
by: Ray Todd Jr | last post by:
I have created a 9 table database. I am wanting have also created a search form so that I can obviously search for the various records in the database. I am however having a problem to which I...
1
by: dskillingstad | last post by:
Would appreciate any help I could get I have an unbound search form with various text boxes on it for searching my database. I would like to have a combo box on the search form where the source...
31
by: DWolff | last post by:
I'm somewhat new to Access, and have no VB experience at all (except for modifying existing code where obvious). I built a data entry form that works fine. Typically, a client will call in and...
1
by: Chris | last post by:
I need a search form to perform. I have a Form and a subform. The subform is based off a query and the main form is unbound. The query runs perfect, however, I have a command button in the main...
6
by: KiwiGenie | last post by:
Hi..I am trying to make a search form. I am fairly new to access and could well be looking at it completely wrong. I have an unbound form with textboxes in the header for entering different search...
2
by: Mark | last post by:
Hi All, I am creating a music database for a friend and have run into a problem. Within the ALBUM table, I wanted to store the ARTIST_ID rather than the ARTIST_NAME. To do this, I intended to have...
16
by: StephR | last post by:
Hello, the users on this site seem to be very helpful. I hope you guys can help me. I have been searching for the past 2 weeks on how to create a search form for my database at work. I'm not really...
2
by: MNNovice | last post by:
I am working on a database on my CD collection using Access 2003. Some of the table structures are given below. Table 1 tblMusicCategory Field 1: MusicCategoryID - Auto Number (PK) Field 2:...
1
by: NLR2008 | last post by:
Hi there, Can anybody help me and provide me with a SIMPLE solution to create a search form in Access 2003. I have created a database for Finance Payments and want to enable the user to...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.