I am obviously new to Access. I need to run a 'select' sql from a button. Everything I find says it wil run any sql except a select one. Any help is thanlfull.
I am obviously new to Access. I need to run a 'select' sql from a button. Everything I find says it wil run any sql except a select one. Any help is thanlfull.
A button can 'open' Access SELECT query object. Why do you need to open query?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Below is my code, which don't work. To answer your queston, it appears (in Access) that the best way to get information from a table is to query it.
Private Sub btnQuery_Click()
' Locate records
Dim db As Database
Dim rst As Recordset
Set db = DBEngine(0)(0)
Set rst = db.OpenRecordset("tblBankRegistar", dbOpenSnapshot)
rst.OpenRecordset "SELECT tblBankRegistar.fTxtAccount, tblBankRegistar.fTxtCheckNo FROM tblBankRegistar"
End Sub
That opens a recordset, not an Access query object.
A recordset can be manipulated in code. Values in fields of recordset can be used in code but there is nothing you can see.
Again, why do you need to open a SELECT query? What do you want to do with the data?
Build form or report with query as RecordSource.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I have to match criteria in 2 different fields to get the next unused check number. There is more than one checking account, so I can't just use the previous high check number or date. I need to match the account number and the check number. What I know about 'findFirst' indicates that only one field can be matched. I appears that in 'seek', the fields must be in the primary index.
FindFirst can have multiple criteria. It's just like the WHERE clause of an SQL statement. Any number of fields can be used with AND or OR operator.
"AccountNumber=" & value & " AND DateEnter=#" & value & "# AND Category='" & value & "'"
Alternative to recordset code is domain aggregate function.
x = DMax("CheckNumber", "tablename", "AccountNumber=" value)
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
That is super. I have 4 books on access and the internet and that is the first I have heard on that. Thank you very much.