How do you create a field on the fly in Access?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am doing a project in Access for class and the teacher told us to create a
field on the fly. I did not get to ask him what he meant. Does anyone know
what he meant?
 
I am doing a project in Access for class and the teacher told us to create a
field on the fly. I did not get to ask him what he meant. Does anyone know
what he meant?

Probably create a calculated field in a Query (not a Table).

John W. Vinson [MVP]
 
Thanks for helping. I will see if that works.

John W. Vinson said:
Probably create a calculated field in a Query (not a Table).

John W. Vinson [MVP]
 
I will ask him however I will see some of the students at college tomorrow at
the lab and will try to find out then.. I was just hoping to get an answer
sooner. Thanks anyway.
 
The only reason that I suggested this is that I taught a beginning level
Access course at a community college in my area for three years. As a
teacher, it can be frustrating grading an assignment where a student's answer
is unrelated to question. I'm sure it was just as frustrating for the
student, especially when they get their homework returned.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
The only reason that I suggested this is that I taught a beginning level
Access course at a community college in my area for three years. As a
teacher, it can be frustrating grading an assignment where a student's answer
is unrelated to question. I'm sure it was just as frustrating for the
student, especially when they get their homework returned.

Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/e...http://www.access.qbuilt.com/html/search.html
__________________________________________





- Show quoted text -

I agree with Tom Wickerath. It is always best to get a clear
definition of the problem before tackling it. One possible meaning of
"create a field on the fly" use VBA.

Try this:

Public Sub main()

Dim sqlStmt As String

On Error GoTo err_main


sqlStmt = "create table MyTable ( MyPrimaryKey Text(10) )"

DoCmd.RunSQL sqlStmt

sqlStmt = "alter table MyTable add MyDataColumn Text(10) "

DoCmd.RunSQL sqlStmt

exit_main:
Exit Sub
err_main:
MsgBox (Err.Description)
End Sub

The first RunSQL will create a table called MyTable. It has a column
called MyPrimaryKey that can a hold a 10-character text string.
The second RunSQL will add a column to MyTable. It is called
MyDataColumn and can hold a 10-character text string.

Sometimes the words "field" and "column" are used interchangeably.

Lou Phillips
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top