Selasa, 03 Juli 2012

[MS_AccessPros] Save from form to table where each item is 1 record; multiselect unbound boxes

 

Hi All!
I am working on creating a form where the parameters that a buyer has can be entered. A couple of criteria can have several items in one category (several cities, several types of houses) and the rest have one response (such as min beds, etc). Those criteria that have several items are selected in a multiselect box. Right now the boxes are unbound and are working to the point that a button can be clicked and it creates a filter which is then applied to another form so that all the houses meeting the parameters are displayed.

***Now I need to change it so that the entries are saved to a table.

The bigger picture is that the next project will be having Access look up buyers that match a new house when it's entered. i.e. Right now I'm working on finding houses when a buyer is entered, and next I'd like to find buyers when a house is entered.

As it stands now the house features are entered into one line on the Listings table. The buyers parameters are supposed to be entered into the SearchParams table with one record per parameter.

Graham had given me input back in March but has not responded to current questions, so I'm reposting this. I am fine if I have to redo because you want to do it a different way.

Info is below.

What would I do without you!! XOX ;-)
Connie

Here are the tables I currently have:

SearchCriteria
==============
CriteriaID (autonumber)
CriteriaName (unique text)(min Bedrooms, max Bedrooms, min bathrooms, max bathrooms, rural, city, housetype, etc.)
CriteriaField (name of field to filter)(Beds, Baths, Rural, City, HouseType, etc.)
CriteriaType (code for text, numeric, etc)
Operator (comparison operator for the WHERE clause)
AllowMulti (boolean - more than one allowed per search)

My SearchCriteria records look like this (I followed Grahams advice but do not know how to use the AllowMulti:true portion) and since I had already created a search form for houses I used that code for creating a filter rather than his operators.

ID:1 Name:MinBedrooms Field:NumBedrooms Type:Numeric Operator:>=
AllowMulti:false
ID:2 Name:MaxBedrooms Field:NumBedrooms Type:Numeric Operator:<=
AllowMulti:false
ID:3 Name:MinBathrooms Field:NumBathrooms Type:Numeric Operator:>=
AllowMulti:false
ID:4 Name:MaxBathrooms Field:NumBathrooms Type:Numeric Operator:<=
AllowMulti:false
ID:5 Name:City Field:City Type:Numeric Operator:IN
AllowMulti:true
ID:6 Name:HouseType Field:HouseType Type:Numeric Operator:IN
AllowMulti:true
(I have tables for Cities and HouseTypes with numeric
PKs)

LookingEvent
==============
LookingID
BeginDate
EndDate
Agent
BuyerType
Notes
SaleID
SearchParams (a junction table joining the above tables)
============
LookingID (foreign key to LookingEvent table)
CriteriaID (Foreign key to SearchCriteria table)
ParamValue (text)
Listings (where the info re house parameters resides)
============
ListID
….
Price
Beds
Baths
Rural
HouseTypeID

The Price will have to be gotten from a query.

Graham had said the following but I don't know how to save from a form to a table where each item is one record and where some data is entered into a Multi select box. I'm leaving my questions regarding the last paragraph until I've been able to save the parameters.
When you save a search, create a Searches record and then create as many
related SearchParams records as required. For example, if the search
specifies at least 2 bedrooms, housetypes 1, 3 or 4 and cities 48 or 56,
then (assuming SearchID is 1) your SearchParams records would look like
this:

1 1 2
1 5 48
1 5 56
1 6 1
1 6 3
1 6 4

Note that the values in the last five records correspond to the selected
items in the Cities and HouseTypes listboxes.

Similarly, when you load a saved search, you can read the SearchParams
records and set/select values in textboxes/listboxes. You could facilitate
this by setting the Tag property of the textbox/listbox to the corresponding
SearchID value.

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar