Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enduser being able to change title of form 2

Status
Not open for further replies.

basco81

Technical User
Jun 18, 2004
17
US
I am attempting to create a form in which the enduser will be able to click a command button and change the title of the form. The title of the form is made up of 4 Label boxes(will change to text if needed).
(Customer)
(Project)
(Location)
(Type of Form)
When the command button is clicked I would like a box to appear and allow the user to enter information that will change the text of the label boxes to fit his/her needs. I have tried to do this by fomulating a new form that pops up with a table that is then linked to the labels(as textboxes) and it kinda works but not the way I am looking for it to work.
Any Suggestions???
 
Hi,

All you need to do is capture the buttons click event and then set the caption of the current form:

Code:
sub myButton_Click ()
    dim l_title as String
    l_title = inputbox "Please enter new title"
    me.caption = l_title
end sub

If you wish to change the description of any text items you will always use the caption identifier.

Hope this helps

Andrew
 
Ok, I think I see what you are doing, but what does the 1_title = inputbox "Please enter new Title" do? I tried it and I am getting a syntax error, I believe that it should make a box pop up to enter the new data in, but can't get it to work.
 
Hi,

Sorry - it should be:

Code:
l_title = inputbox ("Please enter the title")

Andrew
 
Sweet the form is working great now. Just one other question. How do I get the labels on my report to change to this also???
 
Also...Is there a way to make it to where the enduser doesn't have to reenter the data everytime he/she opens the form. Ex. to have the value in the caption box of the label properties actually change???
 
Hi,

It is a similar method:

Code:
me.myLabel.Caption = "This is some text"

Hope this helps.

Andrew
 
Hello,

Easiest way I can think of is to write it to a file and then read it in. For example:

Code:
Sub Form_Load ()
    dim l_caption as string

    open "myFile.txt" for input as #1

    if (eof (1)) then exit sub ' i.e if file is empty

    ' read in details

    line input #1, l_caption

    ' set the caption

    me.caption = l_caption
    close #1
end sub

Sub CmdBtn_Click ()
    dim l_caption as string

    l_caption = inputBox ("Please enter the title")

    ' open the file for output

    open "myFile.txt" for output as #1

    ' set the caption, write to the file and close file

    me.caption = l_caption
    print #1, l_caption
    close #1
end sub

Hope this helps

Andrew
 
IMHO, the easiest way is to maintain a parameters table.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
First off lemme say, thank you so much for helping me with this...i really appreciate it. Second I having troble with the code because it keeps giving me an error saying "file already open" after the first time it opens in the code.
 
Hi,

The reason it is saying that is because you haven't closed the file after the last use or because the file number is in use. Try these suggestions

1. Ensure the file is closed before you open it.
2. Select the next available file number

Code:
dim l_free_file as integer

l_free_file = freefile

close ' close all open files
open "myFile.txt" for input as #l_free_file

If you have files open that you need remaining open in a different section of your code then simply use the freefile section to get the next available file number.

Hope this helps

Andrew
 
Ok...still having troble with the file stuff. But then i also just realized that in order to use the file way I would also have to make the files dynamic correct???...because this way it would only work on my machine. If I created a parameters table as PH suggested how would I get the string to store into the table??
 
Hi,

The files don't need to be dynamic because you are just using them to store on bit of info.....as an alternative, set up a table in Access called TITLE with 1 field called CAPTION_TEXT and use this to store the captions.

Andrew
 
Ok guys, think i am getting very close. I am attemting to use this statement to store the data into the table, is it correct??
DLookup("Customer", "tblParameters") = l_title
because it is giving me the error "object required
 
To store the data:
DoCmd.RunSQL "UPDATE tblParameters SET Customer='" & l_title & "';"
To retrieve the data:
l_title = DLookup("Customer", "tblParameters")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you both...you guys have both been very helpful, I really appreciate it.!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top