List search (1 Viewer)

DatabaseTash

Registered User.
Local time
Today, 22:48
Joined
Jul 23, 2018
Messages
149
I have an existing database of plans. I have searches set up to search for plans one number at a time, but would like to create a way to search for 30+ plans at a time. I would like the user to be able to copy and paste (or import from excel) the plan numbers into a form. The result would then display all matches available in the database and then some how select all the links on that report and open them all.

Is using a form to do this the best way? Or is there a better way? I would like to avoid using code as it is not my strong point. :)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:48
Joined
Oct 29, 2018
Messages
21,467
Hi. For importing the input, you'll probably have to use code. For copying and pasting, I am not 100% sure how you would handle it. If you copy and paste into a box, you'll probably need code to parse it. Maybe you can copy and paste straight to a table. Once you have the user's input into a table, you might be able to use a query to show all matches, and if your plans table already have a link field, then all you have to do is include it in the query, and the user should be able to click on it.
 

DatabaseTash

Registered User.
Local time
Today, 22:48
Joined
Jul 23, 2018
Messages
149
I did consider inputting into a table, but wouldn't that give me results from previous searches aswell as the currant 30 I'm searching for?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:48
Joined
Oct 29, 2018
Messages
21,467
Not if you clean up the table first before using it again. I was thinking of a temporary table.
 

DatabaseTash

Registered User.
Local time
Today, 22:48
Joined
Jul 23, 2018
Messages
149
So is the temporary table in the access table? Would you have to set code to make it clean up the table? I have multiple people using the database at the same time. would that still work?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:48
Joined
Oct 29, 2018
Messages
21,467
Hi. You could use code or macro or ask the user to manually clean up the temporary table first. To properly set up any database to be shared with multiple users, it has to be “split” into a front end and a back end. The temp table will be in the front end, and the data is in the back end. Each user should have their own copy of the front end on their computer.
 

DatabaseTash

Registered User.
Local time
Today, 22:48
Joined
Jul 23, 2018
Messages
149
Oh okay. That's tricky. :)
I do have it split. The Front End is on each user's machine as a short cut to the front end file.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:48
Joined
Oct 29, 2018
Messages
21,467
Sorry no, not a shortcut but an actual copy of the front end on their machines.
 

DatabaseTash

Registered User.
Local time
Today, 22:48
Joined
Jul 23, 2018
Messages
149
Oh okay. That might not be the best way then. Would rather not have to change on each computer each time I make changes to the front end. That is why I have it as a shortcut.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:48
Joined
Oct 29, 2018
Messages
21,467
Unfortunately, it’s considered best practice to have individual copies of the front end. It minimizes data corruption. You won’t be the first one to face the problem of updating multiple copies of the front end. Fortunately, there are plenty of techniques and free tools to make the job less painful. Presumably, a lot less painful than dealing with a corrupted database.
 

DatabaseTash

Registered User.
Local time
Today, 22:48
Joined
Jul 23, 2018
Messages
149
Hi. For importing the input, you'll probably have to use code. For copying and pasting, I am not 100% sure how you would handle it. If you copy and paste into a box, you'll probably need code to parse it. Maybe you can copy and paste straight to a table. Once you have the user's input into a table, you might be able to use a query to show all matches, and if your plans table already have a link field, then all you have to do is include it in the query, and the user should be able to click on it.

With the inputting into the table how would you have users access the table?

Also am I on the right track with this code? I have the temporary table with the data of which I want to find matches for in the tblCadastralPlansRegister.

SELECT temptblBulkSearch.[PlanNumberSearch], tblCadastralPlansRegister.[Date Entered], tblCadastralPlansRegister.[Job], tblCadastralPlansRegister.[Plan Number], tblCadastralPlansRegister.[Portion], tblCadastralPlansRegister.[Section], tblCadastralPlansRegister.[Suburban_Section], tblCadastralPlansRegister.[Plan link], tblCadastralPlansRegister.[Related Job Numbers]
FROM temptblBulkSearch INNER JOIN tblCadastralPlansRegister ON temptblBulkSearch.[PlanNumberSearch] = tblCadastralPlansRegister.[Plan Number];
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:48
Joined
Oct 29, 2018
Messages
21,467
Hi. You actually don’t let users directly access the (or any) table. Instead, you should use forms for user interface. Your query looks good, but I can’t verify it without seeing your tables.
 

DatabaseTash

Registered User.
Local time
Today, 22:48
Joined
Jul 23, 2018
Messages
149
Okay that is the bit I am stuck on; How do I paste a list of Plans into the form? I would like to be able to paste it so the users doesn't need to type the multiple plan numbers in. The users are not fast at typing so I want to make it quick for them.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:48
Joined
Oct 29, 2018
Messages
21,467
Okay that is the bit I am stuck on; How do I paste a list of Plans into the form? I would like to be able to paste it so the users doesn't need to type the multiple plan numbers in. The users are not fast at typing so I want to make it quick for them.
Hi. Like I said earlier, I'm not too sure about copying and pasting. But if you already have the input in Excel, then probably a quicker way is to import it into Access. It's even possible to paste the data into a text file (like using Notepad, for example) and parse the data in Access. In any case, everything I am saying you could do will more than likely involve some form of VBA or macro.
 

DatabaseTash

Registered User.
Local time
Today, 22:48
Joined
Jul 23, 2018
Messages
149
HI TheDBGuy

I have been working on this and set the database up better to allow me to utilise temporary tables in the front end as you suggested.

Now I have a simple form to import an excel spreadsheet into the database, which I would eventually like to use to setup a match query.

I have the following code set up, which works well. The only thing is that the code inserts an additional table.

I'm thinking that it would be easier to append to an existing table and then set up a way to clear the table after each use. I also worry that it would fill the front end up too much if I leave it in the current state. If I have it set up to append to an existing table, knowing the name of the table would make it easier to set up the query.

What would the be the best way to go?


Option Compare Database
Option Explicit


Private Sub btnBrowse_Click()
Dim diag As Office.FileDialog
Dim item As Variant

Set diag = Application.FileDialog(msoFileDialogFilePicker)
diag.AllowMultiSelect = False
diag.Title = "Please select an Excel Spreadsheet (.xlsx files only)"
diag.Filters.Clear
diag.Filters.Add "Excel Spreadsheets", "*.xls, *.xlsx"

If diag.Show Then
For Each item In diag.SelectedItems
Me.TextFileName = item

Next
End If


End Sub

Private Sub btnImportSpreadsheet_Click()
Dim FSO As New FileSystemObject

If Nz(Me.TextFileName, "") = "" Then
MsgBox "Please select a file!"
Exit Sub
End If

If FSO.FileExists(Nz(Me.TextFileName, "")) Then
ExcelImport.ImportExcelSpreadsheet Me.TextFileName, FSO.GetFileName(Me.TextFileName)
Else
MsgBox "File not found!"
End If
End Sub

Private Sub cmdClose_Click()
DoCmd.Close
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:48
Joined
Oct 29, 2018
Messages
21,467
Hi. Is ExcelImport a name of a Module? If so, can you show us the code behind the function called ImportExcelSpreadsheet? Thanks.
 

DatabaseTash

Registered User.
Local time
Today, 22:48
Joined
Jul 23, 2018
Messages
149
Opps. Yes, it is. Here is the code. Thanks

Option Compare Database
Option Explicit

Public Sub ImportExcelSpreadsheet(fileName As String, tableName As String)
On Error GoTo BadFormat
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, tableName, fileName, True
Exit Sub


BadFormat:
MsgBox "The file you tried to import was not an Excel spreadsheet."
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:48
Joined
Oct 29, 2018
Messages
21,467
Hi. Thanks. Okay, I think that code will APPEND the Excel data to the table, if you don't delete it first. So, if that's what you want to do, you can execute a DELETE query against the table before calling that function.
 

Users who are viewing this thread

Top Bottom