Stockwell43 said:
Your a good man Dirk. I most definitely would like to do it the right way.
I
was only trying to go about it the best I know as my experience is a bit
limited. If you are willing to help me do it correctly, the number of
changes
are unimportant. Here is the information of what I believe you were asking
for.
A) tblcollateral, tblloanaccounting, tblimaging, each of these are
separate
tables with data type as Hyperlink. Field names are Collateral,
LoanAccounting and Imaging
B) Name of form is: frmstorage
C) Name of CBO’s: Department and Hyperlink
D) Row Source for Departments: SELECT tbldepartments.Departments FROM
tbldepartments ORDER BY [Departments];
Row Source for Hyperlink: There is none
E) Code in OnChange event or Department CBO:
Private Sub Department_Change()
If Department.Text = "Imaging" Then
Hyperlink.Value = ""
Hyperlink.RowSource = "tblimaging"
ElseIf Department.Text = "Collateral" Then
Hyperlink.Value = ""
Hyperlink.RowSource = "tblcollateral"
ElseIf Department.Text = "Loan Accounting" Then
Hyperlink.Value = ""
Hyperlink.RowSource = "tblloanaccounting"
ElseIf Department.Text = "Spreadsheet" Then
Hyperlink.Value = ""
Hyperlink.RowSource = "tblspreadsheets"
ElseIf Department.Text = "Org Chart" Then
Hyperlink.Value = ""
Hyperlink.RowSource = "tblorgcharts"
ElseIf Department.Text = "Procedure" Then
Hyperlink.Value = ""
Hyperlink.RowSource = "tblProcedures"
Else
End If
End Sub
So, from the look of it, you currently have these "Departments":
Imaging
Collateral
Loan Accounting
Spreadsheet
Org Chart
Procedure
Judging by the rowsource from your Departments combo box, you have a table
named "tbldepartments", which has a field named "Departments". (To me, it
would make more sense for that field to be named "Department", but I don't
want to break anything you've got going now by renaming it.) Is that field
the primary key of the table?
Create another table, named "tblDeptHyperlinks". Give this table two
fields:
Department (type Text)
HyperlinkURL (type Hyperlink)
Make the *combination* of the two fields the primary key of the table. You
do this by selecting both fields and clicking the little "key" icon on the
toolbar.
Now you need to load this table up with the hyperlink values from each
individual department's table. I don't know the names of the fields in
those tables, but suppose the field name in each table is "Hyperlink". Then
you could load the records from tblImaging by executing a query with SQL
like this:
INSERT INTO tblDeptHyperlinks (Department, HyperlinkURL)
SELECT "Imaging", [Hyperlink] FROM tblImaging;
Load the records for each of the other departments with similar queries:
INSERT INTO tblDeptHyperlinks (Department, HyperlinkURL)
SELECT "Collateral", [Hyperlink] FROM tblCollateral;
INSERT INTO tblDeptHyperlinks (Department, HyperlinkURL)
SELECT "Loan Accounting", [Hyperlink] FROM tblLoanAccounting;
INSERT INTO tblDeptHyperlinks (Department, HyperlinkURL)
SELECT "Spreadsheet", [Hyperlink] FROM tblSpreadsheets;
INSERT INTO tblDeptHyperlinks (Department, HyperlinkURL)
SELECT "Org Chart", [Hyperlink] FROM tblOrgCharts;
INSERT INTO tblDeptHyperlinks (Department, HyperlinkURL)
SELECT "Procedure", [Hyperlink] FROM tblProcedures;
Note: if the hyperlink field in these tables is not actually named
"Hyperlink", the above SQL statements will have to be corrected.
If all has gone well so far, tblDeptHyperlinks now contains all the records
you need.
On your form, set the RowSource of your Hyperlink combo box to:
SELECT HyperlinkURL FROM tblDeptHyperlinks
WHERE Department = [Forms]![frmStorage]![Department]
ORDER BY HyperlinkURL;
Note: In the combo box's Row Source property, that statement will all be one
one line, not on three lines as I've posted it for clarity.
Remove the event procedure you have for the Department combo box's Change
event. Delete that code. Instead, add the following event procedure for
the control's AfterUpdate event:
'----- start of code -----
Private Sub Department_AfterUpdate()
Me!Hyperlink.Requery
End Sub
'----- end of code -----
And that ought to do it. If you had forms and reports based on the
individual department tables (tblCollateral, tblLonAccounting, etc.) you
will need to replace them with forms and reports based on tblDeptHyperlinks.
When all is working well, you can get rid of the old tables.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)