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

requery 2

Status
Not open for further replies.

Junkie88

Technical User
Mar 1, 2008
60
US
My form is based on qryQuestionnaire. After going through the recordset, I want to do a requery with new parameters. The code that I am using to do that is given below. but for some reason after requery, my form does not show the new record set.

extractQuestions(2, Me!txtCycleForm, Me!txtPatientID, Me!txtSessionDate, Me!txtSessionID)
Me.Requery
Me.Refresh

Public Function extractQuestions(num As Integer, num2 As Integer, str1 As Integer, str2 As Date, str3 As Long)

Set dbs = CurrentDb
strQueryName = "qryQuestionnaire"

For Each q In dbs.QueryDefs
If q.Name = strQueryName Then
dbs.QueryDefs.Delete strQueryName
End If
Next

'leaving blank for readability
strSQL = ""

Set qryDef = dbs.CreateQueryDef(strQueryName, strSQL)

End function
 
You are creating a query?

Try setting me.recordsource to the value of strSQL. This will reset the current form (where the code ran) yo show records in a new recordset. Make sure all the fields that are visible are included in the SQL.

The requery should happen automatically.

SeeThru
Synergy Connections Ltd - Telemarketing Services

 
for one you are creating a new query with a empty sql
 
new i just did not want to include the long sql statement in this post. i have a comment saying that i am leaving it blank for readability.
 
try

Code:
extractQuestions(2, Me!txtCycleForm, Me!txtPatientID, Me!txtSessionDate, Me!txtSessionID)
me.recordsource = "qryQuestionnaire"
Me.Requery
Me.Refresh
 
instead of deleting and recreating the querry


try

Code:
Public Function extractQuestions(num As Integer, num2 As Integer, str1 As Integer, str2 As Date, str3 As Long)

dim mydb as database 
set mydb=currentdb
strQueryName = "qryQuestionnaire"
sqlstr="????/"
mydb.querydefs(strQueryName).sql=strSQL

end function
 

thanks SeeThru and Pwise. Both suggestions helped me fix different problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top