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

SQL Statement

Status
Not open for further replies.

ohmbru

Technical User
Jul 13, 2001
161
US
I can't get this code to work. Can anyone help me determine what's wrong with my code?


Dim TableName As String
Dim strSQL As String
TableName = Forms![frmUser]![UserID]
DoCmd.OpenTable TableName, acViewNormal, acReadOnly
strSQL = "SELECT * FROM TableName ORDER BY TableName.Mod;"
'strSQL = "SELECT * FROM TableName ORDER BY [Mod];"
DoCmd.RunSQL strSQL



Brian
 
What are you attempting to do? RunSQL will only have a visible action if it is an action query (insert, update, delete); just selecting records won't change the sort order of the open table.

John
 
I am trying to isolate a record which flagged in a previous process. I am looking for a specific record in this table, where [Mod] = -1.

Brian
 
You can't filter the Record or query table output views, but you can do it with forms and reports.
My recommendation would be to create a form or report based on the table, then use something like:

DoCmd.OpenForm "Formname", acNormal, WhereCondition:="mod=-1"

John
 
OK. I have figured out how to get the record I want below. But now I need to update a field in that record to a value on a form. I'm having trouble with the syntax

DoCmd.OpenTable TableName, acViewNormal, acReadOnly
DoCmd.GoToRecord , , acLast

[Projects] = Forms![frmUpdateMe]![Projects] ' = DMax("[Projects]", TableName, "[Begin] > 0")



Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top