subform update

  • Thread starter igg via AccessMonster.com
  • Start date
I

igg via AccessMonster.com

Private Sub A_MainFormButton_To_Update_Subform_Click()
Dim qd As DAO.QueryDef
Set db = CurrentDb
Set qd = db.QueryDefs("Query1")

Dim qstring As String
qstring = "SELECT Table1.* FROM Table1 WHERE id = 1 ORDER BY Table1.ID;"
qd.SQL = qstring

Me.Query1Subform.Form.Requery 'a
'Forms!Form1!Query1Subform.Form.RecordSource = qstring 'b

Set qd = Nothing
Set db = Nothing
End Sub

line 'a , using Requery, does not update the subform.
line 'b ,using RecordSource, updates the subform but in one occasion the
subform fields became locked. Couldn't change the field contents. Could
using 'b cause subform fields get locked?.
 
K

Krzysztof Naworyta

igg via AccessMonster.com wrote:
| Private Sub A_MainFormButton_To_Update_Subform_Click()
| Dim qd As DAO.QueryDef
| Set db = CurrentDb
| Set qd = db.QueryDefs("Query1")
|
| Dim qstring As String
| qstring = "SELECT Table1.* FROM Table1 WHERE id = 1 ORDER BY
| Table1.ID;" qd.SQL = qstring
|
| Me.Query1Subform.Form.Requery 'a
| 'Forms!Form1!Query1Subform.Form.RecordSource = qstring 'b
|
| Set qd = Nothing
| Set db = Nothing
| End Sub
|
| line 'a , using Requery, does not update the subform.
| line 'b ,using RecordSource, updates the subform but in one occasion
| the subform fields became locked. Couldn't change the field
| contents. Could using 'b cause subform fields get locked?.


Private Sub A_MainFormButton_To_Update_Subform_Click()
Dim db as database
Dim qd As DAO.QueryDef

Set db = CurrentDb
Set qd = db.QueryDefs("Query1")

Dim qstring As String
qstring = "SELECT * FROM Table1 WHERE id = 1 ORDER BY ID"
qd.SQL = qstring

'Me.Query1Subform.Form.Requery 'a
With Me.Query1Subform.Form
.RecordSource = .RecordSource
End With

End Sub
 
K

Krzysztof Naworyta

Juzer igg via AccessMonster.com <u53571@uwe> napisa³

| What this basically does?. Can Requery be applied also?.

Try it! ;)

Basically sometimes Form.Requery does not work.
Especially if the background is in MS SQL, but not limited to.
But any assignment to Form.RecordSource does!

So
Me.RecordSource = Me.RecordSource
as far as you can think that nothig changes makes it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top