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

2 quick questions (requeries and checkboxes)

Status
Not open for further replies.

Eric6

Programmer
Jun 11, 2002
54
CA
hello,
i just have 2 quick questions

i was wonderring if i can cause a query (that is not the control source of the form) to requery (in VBA) without having the form change record...

i was able to make the query requery (simply by placing "Requery" in the code) but this makes my form return to the first record
i've worked around this by saving the record position,
then requerying, then going to the saved record...
but the problem is, this causes my form to flicker very badly while the form rapidely changes records.
how can i fix this?

my second question is
how can i check if a checkbox (that is not grouped to anyother) is checked?

thank you for your help
Eric


 
Hi Eric

2nd question first if the check box = -1 or true then it is checked

first question
If your form is requerying then you must either have used queries in your data source that you are requerying or an index sort is being applied in your process and flipping you back to the start

so if you have a button or event that calls the requery process

place this code on it replacing the productid with the field name of the key field in your table & the ME!txtPRODUCTID with the name of the text box holding that data on your form.


Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ProductID] = " & ME!txtPRODUCTID)

call RQMyQuery("qryname" )
Me.Bookmark = rs.Bookmark

then copy the following code into a module

this will requery your query

Sub RQMyQuery(qryname as string)
Dim mydb As Database
Set mydb = CurrentDb
Dim rst As DAO.Recordset, intI As Integer
Set rst = mydb.OpenRecordset(qryname,dbOpenDynaset)
rst.Requery
rst.Close
mydb = Nothing
End Sub

it should stop the flicker
regards

Jo


 
hi Jo
thanks for the help
i forgot to mention this in my first message
but i'm accessing the data from the query in a DLookup

i understand your code, but since i've never worked with recordsets before, i'm not too sure if i'll be able to make it work with my dlookup
i'm not even sure i need the DLookup anymore :)

anyways, thanks for the help
i'll try it out tomorow morning (i'm not at work right now)
if i can't get it to work, i'll just make another post :)

later
Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top