recordset and querydef question

  • Thread starter Thread starter IT
  • Start date Start date
I

IT

Hello,

when i wish to input some values into a table which are created upon the
outcome of clicking a msgbox i use the following code:

Dim qdfquery As QueryDef
SQL = "INSERT INTO A TABLE etc"
Set qdfquery = CurrentDb.CreateQueryDef("", SQL)
qdfquery.Execute

What do people think? is this an efficenct way of doing it?

Also when i wish to check a value within vb code i use the following:

Set rstquery = New ADODB.Recordset

SQL = "SELECT * FROM table WHERE a=1"
rstquery.CursorLocation = adUseClient

rstquery.Open SQL, _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic



If rstquery.EOF = False Then

AValue = rstquery.Fields("Status").Value ' gets the current status
value
Else
AValue = 0
End If

Is this the best way of doing it? Or is it better to get the record set to
point to a query that i have already made? And if so how?

With using adlockoptimisitic what will happen if two people run this query
at the same time? will it crash? what would be a better value


I know there are few questions within this post but any help would be
greatly appreciated!

Cheers

Graham
 
Back
Top