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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I use a form to create a string & populate a field in a table?

Status
Not open for further replies.

MPBCHM

IS-IT--Management
Feb 6, 2002
20
US
I need to create a field that will generate a string using the first 4 letters of one field and the last 4 letters of another. I want the string to populate a field in a table.
Currently, I am using the ControlSource of a Textbox on a form to generate this string but it doesn't update my table.

How can I do this?

Here are my specs...

My Table:
[tblSubmit_Log]
Submit_Id
Submit_Date
HpCode
IpaCode
RecordCount
FileName

My Form:
[frmSubmitLog_Entry]
Submit_Id
Submit_Date
HpCode
IpaCode
RecordCount
Create_FileName

I am using an Expression in the "Create_FileName" field on my form to generate a string. I am using the fields ControlSource to enter the Expression. I need to use the results of this expression to populate a field in my table called "FileName". So far, I am able to create the string on my form but I cannot update my table with this string.

Appreciate the help...

Thanks

Mark
 
FileName needs to be the Control Source of Create_FileName. So whatever read in the Create_FileName will be what in the FileName.

 
Thanks for the quick reply...

What I need to do is create a (string) that takes portions of data from other fields on the same form and combine them.
The data for this string will come from users entering data into textboxs on a form. Then, I want to populate a table based on these fields. Each record has an accompanying text file that I want to name based on this data (string). Once the user enters the data, the macro/module will create a filename (string). A table with the data just entered by the users along with the new (string)needs to be updated once the user closes the form or moves on to the next entry.

I know the controlsource is not where I need to put the code. Thats the only spot that seems to work. I am sure there is another route to take but I am not sure where.

Thanks again...
 
Hi,

I thought previously you said you've been able to create the string already, that's why I just mentioned the control source part.

Well, basically this is the whole process that I've tried and worked just fine.

For example:

In the form that have TableA as record source, you have bound text boxes like txtName, txtDate, txtFileName that come from Table A fields. Then, you have an unbound txtBox where user enters data (txtCreate_FileName).

In the AfterUpdate event of txtCreate_FileName, create an event procedure:
txtFileName = txtName + "/" + txtDate + "/" + txtCreate_FileName

This one will combine/create a new name based on the existing fields value + user's entry.

As txtFileName.controlsource is TableA!FileName, TableA!FileName data will be updated as what is now read in the txtFileName.

Let me know if I still understand incorrectly.

Tin Tin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top