A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How to update control



 
 
Thread Tools Display Modes
  #1  
Old February 19th, 2010, 01:41 PM posted to microsoft.public.access.forms
esee
external usenet poster
 
Posts: 14
Default How to update control

The AfterUpdate Event for a control cboName is NOT updating another
control txtCurTotals on the same form.
What's wrong?

The control txtCurTotals has the following Control Source:
="Current Selections = " & [TotalCount]

TotalCount: DCount("Ingredient","zIngredientAndLocation","[NeedIt] =
True")

Private Sub cboName_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst "[IngredientID] = " & Me![cboName]
If rs.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rs.Bookmark
Me.NeedIt.Value = True
Me.Refresh
End If
rs.Close
Set rs = Nothing
End Sub
  #2  
Old February 19th, 2010, 02:00 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default How to update control

Try using Me.txtCurTotals.Requery rather than Me.Refresh.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"esee" wrote in message
...
The AfterUpdate Event for a control cboName is NOT updating another
control txtCurTotals on the same form.
What's wrong?

The control txtCurTotals has the following Control Source:
="Current Selections = " & [TotalCount]

TotalCount: DCount("Ingredient","zIngredientAndLocation","[NeedIt] =
True")

Private Sub cboName_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst "[IngredientID] = " & Me![cboName]
If rs.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rs.Bookmark
Me.NeedIt.Value = True
Me.Refresh
End If
rs.Close
Set rs = Nothing
End Sub


  #3  
Old February 19th, 2010, 02:49 PM posted to microsoft.public.access.forms
esee
external usenet poster
 
Posts: 14
Default How to update control

On Feb 19, 7:00*am, "Douglas J. Steele"
wrote:
Try using Me.txtCurTotals.Requery rather than Me.Refresh.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)

"esee" wrote in message

...

The AfterUpdate Event for a control cboName is NOT updating another
control txtCurTotals on the same form.
What's wrong?


The control txtCurTotals *has the following Control Source:
="Current Selections = " & [TotalCount]


TotalCount: DCount("Ingredient","zIngredientAndLocation","[NeedIt] =
True")


Private Sub cboName_AfterUpdate()
* Dim rs As DAO.Recordset
* *Set rs = Me.Recordset.Clone
* *rs.FindFirst "[IngredientID] = " & Me![cboName]
* *If rs.NoMatch Then
* * * *MsgBox "Record not found"
* *Else
* * * *Me.Bookmark = rs.Bookmark
* * * *Me.NeedIt.Value = True
* * * *Me.Refresh
* *End If
* *rs.Close
* *Set rs = Nothing
End Sub


I made the change, and the control does not get updated.
  #4  
Old February 19th, 2010, 10:47 PM posted to microsoft.public.access.forms
esee
external usenet poster
 
Posts: 14
Default How to update control

On Feb 19, 7:49*am, esee wrote:
On Feb 19, 7:00*am, "Douglas J. Steele"



wrote:
Try using Me.txtCurTotals.Requery rather than Me.Refresh.


--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)


"esee" wrote in message


....


The AfterUpdate Event for a control cboName is NOT updating another
control txtCurTotals on the same form.
What's wrong?


The control txtCurTotals *has the following Control Source:
="Current Selections = " & [TotalCount]


TotalCount: DCount("Ingredient","zIngredientAndLocation","[NeedIt] =
True")


Private Sub cboName_AfterUpdate()
* Dim rs As DAO.Recordset
* *Set rs = Me.Recordset.Clone
* *rs.FindFirst "[IngredientID] = " & Me![cboName]
* *If rs.NoMatch Then
* * * *MsgBox "Record not found"
* *Else
* * * *Me.Bookmark = rs.Bookmark
* * * *Me.NeedIt.Value = True
* * * *Me.Refresh
* *End If
* *rs.Close
* *Set rs = Nothing
End Sub


I made the change, and the control does not get updated.


For those interested, I solved my problem. I still don't understand
why my original AfterUpdate code didn't work, but this NEW AfterUpdate
code works, and leaves me on the current at the same time.

Private Sub cboName_AfterUpdate()
Dim lngKeyVal As Long
'Save the value for the current record
lngKeyVal = Me.cboName
'Requery the form
Me.Requery
'Move back to the original record
With Me.RecordsetClone
..FindFirst "[IngredientID] = " & lngKeyVal
If Not .NoMatch Then
Me.Bookmark = .Bookmark
Me.NeedIt.Value = True
Me.Requery
Me.Refresh
End If
End With

'Move back to the original record...AGAIN
With Me.RecordsetClone
..FindFirst "[IngredientID] = " & lngKeyVal
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
End Sub
  #5  
Old March 20th, 2010, 09:52 PM posted to microsoft.public.access.forms
love[_3_]
external usenet poster
 
Posts: 10
Default How to update control


"esee" wrote in message
...
The AfterUpdate Event for a control cboName is NOT updating another
control txtCurTotals on the same form.
What's wrong?

The control txtCurTotals has the following Control Source:
="Current Selections = " & [TotalCount]

TotalCount: DCount("Ingredient","zIngredientAndLocation","[NeedIt] =
True")

Private Sub cboName_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst "[IngredientID] = " & Me![cboName]
If rs.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rs.Bookmark
Me.NeedIt.Value = True
Me.Refresh
End If
rs.Close
Set rs = Nothing
End Sub


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.