Searching Multiple Form Databases (complete newbie, really need help) (1 Viewer)

kamil

New member
Local time
Today, 04:54
Joined
Jul 15, 2002
Messages
5
Here's the situation:

My company basically plopped this down on me; I have 2 database files with about 60 or so form databases within them(or whatever they're called -- im totally new to access). Within these form databases I have anywhere from 1-40 records. I have a list of entries from an excel spreadsheet that are incomplete -- they only have part of the required information and therefore cannot be filed away. In order to fill in the rest of the info, the correct form must be found by using any part of the partial information from the excel sheet.

So, I need to know if there's any way to search all the records in all the form databases at once for any given value. Say I have a company name from the excel sheet but nothing else. Instead of looking through each and every single record manually (what my company expects me to do right now -- this will take days if not weeks for all the records and would have to be repeated every single month), I would like to somehow search for this value. Can this be done? If so, what does it entail?

I am a newbie to access but am very fluent with all nature of computer software so if explained I can more than likely set it up. I have worked with mySql databases but never with access -- this stuff seems completely different.

Thanks!
 

cogent1

Registered User.
Local time
Today, 04:54
Joined
May 20, 2002
Messages
315
An Access database contains Tables, Forms, Queries, Reports and code modules in one mdb file.

You are probably referring to TABLES when you mention FORM DATABASES. Assuming this to be the case, how much commonality exists between the tables? How similar are they in terms of field name/types? Would they lend themselves to simplification? Can they be concatenated to make searches easier?

Searching through the tables is possible of course, but the exact means of doing that depends on the structure of your database.
 

kamil

New member
Local time
Today, 04:54
Joined
Jul 15, 2002
Messages
5
Actually, the forms are what need searching -- they are all filled out with information. The information contained is almost identical in every form -- by this I mean all field types/number of fields etc are the same. These records contain the same type of information -- only the actual information changes. Is this searchable?
 

cogent1

Registered User.
Local time
Today, 04:54
Joined
May 20, 2002
Messages
315
Underlying each of the forms is a recordset based on a table or a query. Probably some of the forms contain different subsets of the same table data. The facr that they are all similar in structure points to some common origin. (unless it's a poorly designed database)

If you are just looking for the occurrence of a particular value, it's quicker to open one recordset and scan through it than to open all the forms and index through their underlying recordsets. So some additional info on your database structure would be a useful guide.
 

kamil

New member
Local time
Today, 04:54
Joined
Jul 15, 2002
Messages
5
Working with this page:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q210242

I have modified it to use the OR statement so any criteria matched is outputted:

Code:
Private Sub cmdRunQuery_Click()
Dim db As DAO.Database
Dim QD As QueryDef
Dim where As Variant

Set db = CurrentDb()

' Delete the existing dynamic query; trap the error if the query does
' not exist.
On Error Resume Next
db.QueryDefs.Delete ("Dynamic_Query")
On Error GoTo 0

' Note the single quotation marks surrounding the text fields [Ship
' Country] and [CustomerID].
' Note that there are no type-casting characters surrounding the
' numeric field [EmployeeID].

where = Null
where = where & " AND [ShipCountry]= '" + Me![Ship Country] + "'"
where = where & " AND [CustomerID]= '" + Me![Customer Id] + "'"
where = where & " AND [EmployeeID]= " + Me![Employee Id]

'NOTE: In Microsoft Access, when you use the plus sign (+) in an
'expression in which you are concatenating a variable of the numeric
'data type, you must use parenthesis around the syntax, as in the
'following example:
'
'  where = where & (" AND [EmployeeID]= " + Me![Employee Id])
'
'You must also use a conversion function to make sure that the proper
'conversion (to either NULL or String) takes place.

' The following section evaluates the ShipCity criteria you enter.
' If the first or last character of the criteria is the wildcard
' character (*), then the function uses the "LIKE" operator in the
' SQL statement instead of "=". Also note the single quotation
' marks surrounding the text field [ShipCity].
If Left(Me![Ship City], 1) = "*" Or Right(Me![Ship City], 1) = "*" Then
   where = where & " OR [ShipCity] like '" + Me![Ship City] + "'"
Else
   where = where & " OR [ShipCity] = '" + Me![Ship City] + "'"
End If

' Note the number signs (#) surrounding the date field [Order Date].
If Not IsNull(Me![Order End Date]) Then
   where = where & " OR [OrderDate] between #" + Me![Order Start Date] + "# AND #" & Me![Order End Date] & "#"
Else
   where = where & " OR [OrderDate] >= #" + Me![Order Start Date] + " #"
End If

' Remove the following MsgBox line if you do not want to display the
' SQL statement.
' NOTE: The Mid function is used in the following MsgBox function to
' remove the word AND that follows the first Where clause. If you do
' not use the Mid function, the SQL statement contains the word AND
' at the beginning of the WHERE clause, for example:
'
'   Select * from Orders where AND [CustomerID] = 'CACTU'
MsgBox "Select * from Orders " & (" where " + Mid(where, 5) & ";")
Set QD = db.CreateQueryDef("Dynamic_Query", "Select * from orders " & (" where " + Mid(where, 5) & ";"))
DoCmd.OpenQuery "Dynamic_Query"

End Sub

This code however does not cover everything I need the query to do.

For one, I need to have the form search more than the table its based on, I have over 60 tables that need to be searched.

Second, when the tables are searched for the criteria I need to have the query return the results "by table" so I know where the results came from (which table).

Anyone kind enough to take a stab at it? Please post replies in the new thread in the VBA forum:
http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=31520
 
Last edited:

Users who are viewing this thread

Top Bottom