Dmax showing value

  • Thread starter Thread starter Ellen Leonard via AccessMonster.com
  • Start date Start date
E

Ellen Leonard via AccessMonster.com

I have the following code in a subform

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![Cycle_Number] = Nz(DMax("Cycle_Number", "Inbound", "[CustomerID] = " &
[Forms]![Mid Tier Customers]![CustomerID]), 0) + 1

End Sub

and it works!

However, the field "Cycle_Number" doesn't show the value until I leave the
record and return. How do I have the value show up right away so the user
can see it.

Thanks all for your help.
 
after the assignment, use

DoEvents

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
I added DoEvents to the subform code but it still doesn't fill in value until
I leave and return to record. What am I missing?

Thanks for helping btw
after the assignment, use

DoEvents

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
I have the following code in a subform
[quoted text clipped - 11 lines]
Thanks all for your help.
 
When is "right away"? The soonest you can do it is after [Forms]![Mid Tier
Customers]![CustomerID] has a valid value. Looking at your code, this form
is either a sub form to that form or a different form, so you may be able to
do it in the Current event of the form. You would only have to check to be
sure you are doing this to a new record:

If Me.NewRecord Then
Me![Cycle_Number] = Nz(DMax("Cycle_Number", "Inbound", "[CustomerID] = " &
[Forms]![Mid Tier Customers]![CustomerID]), 0) + 1
End If
 
Yes, this is a subform. I am added records to the subform so the customerID
is already a valid value. Tried you code in both Before update and Current
Event.... still need to move off record to get it to refresh.

Also tried adding

DoEvents
Me.Refresh

to the end of the code and that hasn't changed anything.


When is "right away"? The soonest you can do it is after [Forms]![Mid Tier
Customers]![CustomerID] has a valid value. Looking at your code, this form
is either a sub form to that form or a different form, so you may be able to
do it in the Current event of the form. You would only have to check to be
sure you are doing this to a new record:

If Me.NewRecord Then
Me![Cycle_Number] = Nz(DMax("Cycle_Number", "Inbound", "[CustomerID] = " &
[Forms]![Mid Tier Customers]![CustomerID]), 0) + 1
End If
I have the following code in a subform
[quoted text clipped - 11 lines]
Thanks all for your help.
 
how about

Me.[Cycle_Number].requery

also, since you are in a subform, you can do this:
me.parent.CustomerID

instead of this:

[Forms]![Mid Tier Customers]![CustomerID]


Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com


Yes, this is a subform. I am added records to the subform so the customerID
is already a valid value. Tried you code in both Before update and Current
Event.... still need to move off record to get it to refresh.

Also tried adding

DoEvents
Me.Refresh

to the end of the code and that hasn't changed anything.


When is "right away"? The soonest you can do it is after [Forms]![Mid Tier
Customers]![CustomerID] has a valid value. Looking at your code, this form
is either a sub form to that form or a different form, so you may be able to
do it in the Current event of the form. You would only have to check to be
sure you are doing this to a new record:

If Me.NewRecord Then
Me![Cycle_Number] = Nz(DMax("Cycle_Number", "Inbound", "[CustomerID] = " &
[Forms]![Mid Tier Customers]![CustomerID]), 0) + 1
End If

I have the following code in a subform

[quoted text clipped - 11 lines]
Thanks all for your help.
 
Thank you so much for your help. I put the Me.refresh in the Contact_Date
field which I made a required field and since it has to be filed in the
record set gets refreshed and the user gets the Issue number.

Thank you again for all your help and the me.parent tip
how about

Me.[Cycle_Number].requery

also, since you are in a subform, you can do this:
me.parent.CustomerID

instead of this:

[Forms]![Mid Tier Customers]![CustomerID]

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
Yes, this is a subform. I am added records to the subform so the customerID
is already a valid value. Tried you code in both Before update and Current
[quoted text clipped - 23 lines]
 
you're welcome, Ellen ;) happy to help

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
remote programming and training


Thank you so much for your help. I put the Me.refresh in the Contact_Date
field which I made a required field and since it has to be filed in the
record set gets refreshed and the user gets the Issue number.

Thank you again for all your help and the me.parent tip
how about

Me.[Cycle_Number].requery

also, since you are in a subform, you can do this:
me.parent.CustomerID

instead of this:

[Forms]![Mid Tier Customers]![CustomerID]

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com

Yes, this is a subform. I am added records to the subform so the customerID
is already a valid value. Tried you code in both Before update and Current

[quoted text clipped - 23 lines]
Thanks all for your help.
 
Back square one. If I change the date the issue number increases.... This
also happens if I put the DMax code in ON CURRENT rather than BEFORE UPDATE.
Anyone have any more ideas how to increment a number and then have it not
change?

Thanks
you're welcome, Ellen ;) happy to help

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
remote programming and training
Thank you so much for your help. I put the Me.refresh in the Contact_Date
field which I made a required field and since it has to be filed in the
[quoted text clipped - 27 lines]
 
Hi Ellen,

are you wanting this to get assigned just when you create a
new record?

If so, do you have code in the BeforeUpdate event of the
record which would prevent the record from being saved when
it is first started?

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com

Back square one. If I change the date the issue number increases.... This
also happens if I put the DMax code in ON CURRENT rather than BEFORE UPDATE.
Anyone have any more ideas how to increment a number and then have it not
change?

Thanks
you're welcome, Ellen ;) happy to help

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
remote programming and training

Thank you so much for your help. I put the Me.refresh in the Contact_Date
field which I made a required field and since it has to be filed in the

[quoted text clipped - 27 lines]
Thanks all for your help.
 
Then in Save button click event:
Me.Dirty = False
Will do the update

Ellen Leonard via AccessMonster.com said:
Yes, this is a subform. I am added records to the subform so the customerID
is already a valid value. Tried you code in both Before update and Current
Event.... still need to move off record to get it to refresh.

Also tried adding

DoEvents
Me.Refresh

to the end of the code and that hasn't changed anything.


When is "right away"? The soonest you can do it is after [Forms]![Mid Tier
Customers]![CustomerID] has a valid value. Looking at your code, this form
is either a sub form to that form or a different form, so you may be able to
do it in the Current event of the form. You would only have to check to be
sure you are doing this to a new record:

If Me.NewRecord Then
Me![Cycle_Number] = Nz(DMax("Cycle_Number", "Inbound", "[CustomerID] = " &
[Forms]![Mid Tier Customers]![CustomerID]), 0) + 1
End If
I have the following code in a subform
[quoted text clipped - 11 lines]
Thanks all for your help.
 
Back
Top