Hello and again Thank you very much for any assistance you can provide.
Based on guidance provided by Cliff, this is where I am at so far.
First I will attempt describe as best I can what you don't see.
The form I am working on is a sub-form of a primary form. The display
format
is datasheet view, there are 4 columns, Lbound in row 1 will always be 0.
There are 11 records ID 1 - 11.
What I have written here seems to work in all situations that I have
tested
except one (If a user make a change to Ubound in row2 then clicks on
Ubound
in row4, Lbound in row3 never gets set to the correct value.
So my question; is there a way perhaps using the ID field to set the value
of Lbound of row3 when focus is lost on Ubound of row2?
======================
Private Sub Form_Open(Cancel As Integer)
On Error GoTo ProcError
Me.Ubound.SetFocus
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdEndDate_Click..."
Resume ExitProc
End Sub
======================
Private Sub Lbound_GotFocus()
On Error GoTo ProcError
If Me.ID = (Me.ctl_prvID + 1) Then
Me.Lbound = Me.ctl_prvUbound
End If
ExitProc:
Me.Ubound.SetFocus
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdEndDate_Click..."
Resume ExitProc
End Sub
======================
Private Sub Ubound_LostFocus()
On Error GoTo ProcError
If Me.ID = 1 Then
Me.ctl_prvUbound = Me.Ubound
Else
If Me.ID = (Me.ctl_prvID + 1) Then
Me.Lbound = Me.ctl_prvUbound
End If
Me.ctl_prvUbound = Me.Ubound
Me.ctl_prvID = Me.ID
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdEndDate_Click..."
Resume ExitProc
End Sub
==========================================
==========================================
Clif McIrvin said:
MVP - WannaB said:
Hello, I'm not sure that subject line is exactly right for this but in
my
head it sounded close.
I have a form with 4 columns of data (ID, Lbound, Ubound, and
Description).
There are 11 rows of data that a user can modify, and because Lbound
in every
row needs to be the same as Ubound of the previous row I would like to
GET
the value of Ubound for each row and SET the value of Lbound. So the
user
only needs to enter or modify the value for Ubound and the
description. Is
GET and SET the right functions to use or am I getting VBA mixed up
with VB?
And can someone start me in the right direction to accomplish this?
Thanks
for your help in advance. I truly appreciate all your help and still
hope to
be able to help others one of these days.
In VBA GET and SET relate to properties of class objects --- different
subject altogether. (In the VBA editor, type class module into the help
search and have fun reading! Some developers write class modules, others
don't, from what I hear.)
Are the Lbound and Ubound values required?
Can the user 'jump around' in the 11 rows? That is, can you guarantee
that the user will always progress sequentially through the rows? In my
experience that's generally a bad assumption.
Assuming an initial data entry environment where the user always
proceeds sequentially 'down' the form something along these lines:
In the form (or Ubound control) AfterUpdate event set the default value
for Lbound [assuming that the next row hasn't been added to the table
yet.]
ctlLbound.DefaultValue = ctlUbound.Value
(DefultValue is always a string --- in some situations you need to
handle the data type conversion yourself.)
If the 11 rows are already present in the table the default value won't
help you. In this situation you can use the form's Current event to set
the Lbound value. I have also used the form's Before Insert event
instead of the current event so that I only modify a control's value if
the user begins typing a value into any control; the Current event will
fire anytime the current record pointer changes for any reason.
HTH