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

SQL, Field name alias for write access

Status
Not open for further replies.

TLowder

Programmer
Mar 20, 2002
224
Hello,
I get an error on the adorec.update line - Unknown column 'MyName' in 'field list'. The code will work for read access but won't let me write to it. How do I update a field with an alias?

I know i can lose the "AS" part but that would defeat the purpose of what I'm accually trying to do. This is just a sample.

Thanks,
Tom

'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim sql As String
Dim adocon As ADODB.Connection
Dim adorec As Recordset

Set adocon = New ADODB.Connection
Set adorec = New ADODB.Recordset

adorec.CursorLocation = adUseClient

adocon.ConnectionString = gConnectionString

adocon.Open

sql = "SELECT BanquetItemsTbl.Name as MyName FROM BanquetItemsTbl"
adorec.Open sql, adocon, adOpenDynamic, adLockOptimistic

adorec.AddNew
adorec!MyName = "TestName"

adorec.Update
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
I worked around the above problem but I'm still curious about this so I thought I'd bring it back to the top of the board. Also I have a similiar problem that could be resolved if I knew the solution to the "as" problem.

The new problem is when you have a join of two tables with like field names. I always did this way when it was an access database -

Code:
adorec![Table1.Name] = "x"
adorec![Table2.Name] = "y"

I also used the brckets for reserved words in access. It doesn't seem to like the brackets in MySQL. What is syntax for MySQL?

Thanks,
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top