Form Name automatically Database Name

cterjesen

Board Regular
Joined
Jun 23, 2003
Messages
119
Is there a way to have a Form automatically be named the same as the database name? I have limited knowledge of programming, so please be specific if it requires writing code somewhere (where?).

Also, is it possible to have the Autoexec macro I have (which automatically opens the Form) know the name of the form based on the name of the file?

Thanks!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi, it is possible to do what you want but if you're just wanting a specific form to open when you launch the application, there is a simpler way.
Go to Tools | Startup and, in the top right section of the dialog, select the startup from from the drop-down list. Next time you launch the database, that form will open.

Denis
 
Upvote 0
Hey, that works great. Thanks!

Is there any way to have the Form Name automatically be the same name as the database name?

So if I copy the database and rename it "Version 2", the form name would also be "Version 2".

Thanks for your help!
 
Upvote 0
I have never given a form a dynamic name, purely because of the grief it causes for anything that refers to the form. In Access, name changes don't cascade through the database so you'll end up with any number of errors.
However, I guess you could change the caption of the form or one of its labels dynamically. That would not be such a reference problem -- but I'll have to wait till I get home to test it out (no Access at work, currently 11 am...)

Denis
 
Upvote 0
I have never given a form a dynamic name, purely because of the grief it causes for anything that refers to the form. In Access, name changes don't cascade through the database so you'll end up with any number of errors.
However, I guess you could change the caption of the form or one of its labels dynamically. That would not be such a reference problem -- but I'll have to wait till I get home to test it out (no Access at work, currently 11 am...)

Denis
 
Upvote 0
I agree with Denis about renaming the form.

But as he says you could use something like this to change the caption of the form:

Code:
Private Sub Form_Load()
    Me.Caption = CurrentDb.Name
End Sub
 
Upvote 0
You guys have convinced me. The added benefit of doing this is not worth the added headaches it sounds like it will create.

Thanks!

P.S. Any idea why my text information from Excel does not come over into my Access table when I use the TransferSpreadsheet Action in a macro? I've checked the table and the field type is text. I'm getting blanks when I use this macro where the text should be. The same is happening with date format data. The numeric data comes over fine.
 
Upvote 0
cterjesen

Perhaps you could explain your new problem a little further.

It might also be an idea to create a new post.

EDIT
Sorry I noticed you did do a new post.
 
Upvote 0
Have you tried just linking the Excel file direct to the database? Assumptions:
1. The Excel table starts on Row 1 of the worksheet, with headings.
2. The Excel columns have been given specific data types, eg not just General

That way, all data from the spreadsheet is immediately available in Access without needing to run an import. The major issue is that linked Excel tables can be sluggish -- but you can periodically run a MakeTable query to push the Excel data to a native Access table.

Denis
 
Upvote 0

Forum statistics

Threads
1,221,845
Messages
6,162,350
Members
451,760
Latest member
samue Thon Ajaladin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top