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!

Prompt user for field name in update query?

Status
Not open for further replies.

mrtroy

Technical User
Jan 28, 2003
23
US
How can I prompt a user for a field name and use that name in the update query...ie...the tables in question have 12 columns, one for each month....the colmuns are named 01, 02, 03 etc....i want the user to input the appropriate column name have the query update just that column...Thanks in advance
 
I understand why you say that, but I'm dealing with a database that was already constructed when the project was passed to me...i recognize that if i were allowed to change the database then my problem would more or less go away...but i can't...
 
I am not aware of a method of doing this that doesn't involve writing some code. Your main issue is that your table is not normalized. You shouldn't use month numbers as field names.

A normalized table would have the month as a value. You could then do an update of all the records where the Month field is a particular value.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Instead of using a access query try using a VB script query.

Idea: Use a form for the user to select the column to update. Either using a combo box or a list box. Then create a button and attach this code to it.

dim strSQL as string, strColNme as string

Sub Button_click()

strColNme = Me!feild name
strSQL = "update tbl set tbl." & strColNme & "= Data"
docmd.runsql strSQL

End sub

I think this will help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top