Last Rec or New Record

  • Thread starter Thread starter Russ
  • Start date Start date
R

Russ

I have an application which allows two of four shifts each
to enter data based on which shift they belong to, day or
night.
'
There are two drop down boxes allowing the imput of the
shift value represented at the time. cbo1 = DayShift and
cbo2 = NightShift

The first shift begins at 7:00 AM with the second shift
beginning at 7:00PM. Each shift consists of 12 hours. The
application has a main form that swaps out sub-forms for
each aspect of the shift's assignments.

Currently I have the sub-forms opening in the "OnLoad"
event to acLastRec when they are called/swapped. What I'd
like to do is have the sub-form look to see if either or
both of the shift (cbo1 or cbo2) controls have a value or
not, if cbo1 has a value and cbo2 does not, open to
acLastRec. If both cbo1 and cbo2 already have a value do
not open to acLastRec, open to acNewRec, which would be a
new day/date since both shifts have already completed data
entry for the previous day/date and it's now a new day and
shift.

Is this possible? How???

Thanks,...
 
In your code, after you load the subform, put this code snippet (change
names to your actual names; code not tested) -- note that this code assumes
that you're running code in the subform; if it's in the main form, it'll
need to be a bit different:

If Len(Me.cbo1.Value & "") <> 0 And Len(Me.cbo2.Value) <> 0 Then _
Me.Recordset.AddNew

If the code is running in the main form, then the code snippet would be
similar to this:

If Len(Me.Subform!cbo1.Value & "") <> 0 And _
Len(Me.Subform!cbo2.Value) <> 0 Then _
Me.Subform.Form.Recordset.AddNew

(where Subform is the name of the subform control [ the control on the main
form that holds the subform ] ).
 
Ken:

I keep getting the error: "Method Or Data Member Not
Found" after I plugged the code as you stated in the sub-
form.

Since I'm new at this, can you assist further?

Thanks,


-----Original Message-----
In your code, after you load the subform, put this code snippet (change
names to your actual names; code not tested) -- note that this code assumes
that you're running code in the subform; if it's in the main form, it'll
need to be a bit different:

If Len(Me.cbo1.Value & "") <> 0 And Len(Me.cbo2.Value) <> 0 Then _
Me.Recordset.AddNew

If the code is running in the main form, then the code snippet would be
similar to this:

If Len(Me.Subform!cbo1.Value & "") <> 0 And _
Len(Me.Subform!cbo2.Value) <> 0 Then _
Me.Subform.Form.Recordset.AddNew

(where Subform is the name of the subform control [ the control on the main
form that holds the subform ] ).


--
Ken Snell
<MS ACCESS MVP>

I have an application which allows two of four shifts each
to enter data based on which shift they belong to, day or
night.
'
There are two drop down boxes allowing the imput of the
shift value represented at the time. cbo1 = DayShift and
cbo2 = NightShift

The first shift begins at 7:00 AM with the second shift
beginning at 7:00PM. Each shift consists of 12 hours. The
application has a main form that swaps out sub-forms for
each aspect of the shift's assignments.

Currently I have the sub-forms opening in the "OnLoad"
event to acLastRec when they are called/swapped. What I'd
like to do is have the sub-form look to see if either or
both of the shift (cbo1 or cbo2) controls have a value or
not, if cbo1 has a value and cbo2 does not, open to
acLastRec. If both cbo1 and cbo2 already have a value do
not open to acLastRec, open to acNewRec, which would be a
new day/date since both shifts have already completed data
entry for the previous day/date and it's now a new day and
shift.

Is this possible? How???

Thanks,...


.
 
You didn't state whether the code is running in the main form's module or in
the subform's module. Need to know this before I can debug further.

--
Ken Snell
<MS ACCESS MVP>

Russ said:
Ken:

I keep getting the error: "Method Or Data Member Not
Found" after I plugged the code as you stated in the sub-
form.

Since I'm new at this, can you assist further?

Thanks,


-----Original Message-----
In your code, after you load the subform, put this code snippet (change
names to your actual names; code not tested) -- note that this code assumes
that you're running code in the subform; if it's in the main form, it'll
need to be a bit different:

If Len(Me.cbo1.Value & "") <> 0 And Len(Me.cbo2.Value) <> 0 Then _
Me.Recordset.AddNew

If the code is running in the main form, then the code snippet would be
similar to this:

If Len(Me.Subform!cbo1.Value & "") <> 0 And _
Len(Me.Subform!cbo2.Value) <> 0 Then _
Me.Subform.Form.Recordset.AddNew

(where Subform is the name of the subform control [ the control on the main
form that holds the subform ] ).


--
Ken Snell
<MS ACCESS MVP>

I have an application which allows two of four shifts each
to enter data based on which shift they belong to, day or
night.
'
There are two drop down boxes allowing the imput of the
shift value represented at the time. cbo1 = DayShift and
cbo2 = NightShift

The first shift begins at 7:00 AM with the second shift
beginning at 7:00PM. Each shift consists of 12 hours. The
application has a main form that swaps out sub-forms for
each aspect of the shift's assignments.

Currently I have the sub-forms opening in the "OnLoad"
event to acLastRec when they are called/swapped. What I'd
like to do is have the sub-form look to see if either or
both of the shift (cbo1 or cbo2) controls have a value or
not, if cbo1 has a value and cbo2 does not, open to
acLastRec. If both cbo1 and cbo2 already have a value do
not open to acLastRec, open to acNewRec, which would be a
new day/date since both shifts have already completed data
entry for the previous day/date and it's now a new day and
shift.

Is this possible? How???

Thanks,...


.
 
Ken:

Both, at times at Main Form's module level, at others at
the Sub-Form module level.

Thanks,...

-----Original Message-----
You didn't state whether the code is running in the main form's module or in
the subform's module. Need to know this before I can debug further.

--
Ken Snell
<MS ACCESS MVP>

Ken:

I keep getting the error: "Method Or Data Member Not
Found" after I plugged the code as you stated in the sub-
form.

Since I'm new at this, can you assist further?

Thanks,


that
this code assumes
0 Then _
Me.Recordset.AddNew

If the code is running in the main form, then the code snippet would be
similar to this:

If Len(Me.Subform!cbo1.Value & "") <> 0 And _
Len(Me.Subform!cbo2.Value) <> 0 Then _
Me.Subform.Form.Recordset.AddNew

(where Subform is the name of the subform control [ the control on the main
form that holds the subform ] ).


--
Ken Snell
<MS ACCESS MVP>

I have an application which allows two of four shifts each
to enter data based on which shift they belong to,
day
or
night.
'
There are two drop down boxes allowing the imput of the
shift value represented at the time. cbo1 = DayShift and
cbo2 = NightShift

The first shift begins at 7:00 AM with the second shift
beginning at 7:00PM. Each shift consists of 12 hours. The
application has a main form that swaps out sub-forms for
each aspect of the shift's assignments.

Currently I have the sub-forms opening in the "OnLoad"
event to acLastRec when they are called/swapped. What I'd
like to do is have the sub-form look to see if either or
both of the shift (cbo1 or cbo2) controls have a
value
or
not, if cbo1 has a value and cbo2 does not, open to
acLastRec. If both cbo1 and cbo2 already have a value do
not open to acLastRec, open to acNewRec, which would
be
a
new day/date since both shifts have already completed data
entry for the previous day/date and it's now a new
day
and
shift.

Is this possible? How???

Thanks,...


.


.
 
Do you get the same error in both situations? Or different error for main
form and for subform? Perhaps you can post the code from both modules?

--
Ken Snell
<MS ACCESS MVP>

Russ said:
Ken:

Both, at times at Main Form's module level, at others at
the Sub-Form module level.

Thanks,...

-----Original Message-----
You didn't state whether the code is running in the main form's module or in
the subform's module. Need to know this before I can debug further.

--
Ken Snell
<MS ACCESS MVP>

Ken:

I keep getting the error: "Method Or Data Member Not
Found" after I plugged the code as you stated in the sub-
form.

Since I'm new at this, can you assist further?

Thanks,



-----Original Message-----
In your code, after you load the subform, put this code
snippet (change
names to your actual names; code not tested) -- note that
this code assumes
that you're running code in the subform; if it's in the
main form, it'll
need to be a bit different:

If Len(Me.cbo1.Value & "") <> 0 And Len(Me.cbo2.Value)
0 Then _
Me.Recordset.AddNew

If the code is running in the main form, then the code
snippet would be
similar to this:

If Len(Me.Subform!cbo1.Value & "") <> 0 And _
Len(Me.Subform!cbo2.Value) <> 0 Then _
Me.Subform.Form.Recordset.AddNew

(where Subform is the name of the subform control [ the
control on the main
form that holds the subform ] ).


--
Ken Snell
<MS ACCESS MVP>

message
I have an application which allows two of four shifts
each
to enter data based on which shift they belong to, day
or
night.
'
There are two drop down boxes allowing the imput of the
shift value represented at the time. cbo1 = DayShift and
cbo2 = NightShift

The first shift begins at 7:00 AM with the second shift
beginning at 7:00PM. Each shift consists of 12 hours.
The
application has a main form that swaps out sub-forms for
each aspect of the shift's assignments.

Currently I have the sub-forms opening in the "OnLoad"
event to acLastRec when they are called/swapped. What
I'd
like to do is have the sub-form look to see if either or
both of the shift (cbo1 or cbo2) controls have a value
or
not, if cbo1 has a value and cbo2 does not, open to
acLastRec. If both cbo1 and cbo2 already have a value do
not open to acLastRec, open to acNewRec, which would be
a
new day/date since both shifts have already completed
data
entry for the previous day/date and it's now a new day
and
shift.

Is this possible? How???

Thanks,...


.


.
 
Ken:

Here is the code:

If Len(Me.cboDayShift.Value & "") <> 0 And Len
(Me.cboNigthShift.Value) <> 0 Then _
Me.Recordset.AddNew
End If

The error generated targets the "Me.Recordset.AddNew" part
of the code in both instances with the "Method Or Data
Member Not Found" error.

This may help in the debugging.

Thanks,....

-----Original Message-----
Do you get the same error in both situations? Or different error for main
form and for subform? Perhaps you can post the code from both modules?

--
Ken Snell
<MS ACCESS MVP>

Ken:

Both, at times at Main Form's module level, at others at
the Sub-Form module level.

Thanks,...

-----Original Message-----
You didn't state whether the code is running in the
main
form's module or in
the subform's module. Need to know this before I can debug further.

--
Ken Snell
<MS ACCESS MVP>

Ken:

I keep getting the error: "Method Or Data Member Not
Found" after I plugged the code as you stated in the sub-
form.

Since I'm new at this, can you assist further?

Thanks,



-----Original Message-----
In your code, after you load the subform, put this code
snippet (change
names to your actual names; code not tested) -- note that
this code assumes
that you're running code in the subform; if it's in the
main form, it'll
need to be a bit different:

If Len(Me.cbo1.Value & "") <> 0 And Len
(Me.cbo2.Value)
0 Then _
Me.Recordset.AddNew

If the code is running in the main form, then the code
snippet would be
similar to this:

If Len(Me.Subform!cbo1.Value & "") <> 0 And _
Len(Me.Subform!cbo2.Value) <> 0 Then _
Me.Subform.Form.Recordset.AddNew

(where Subform is the name of the subform control [ the
control on the main
form that holds the subform ] ).


--
Ken Snell
<MS ACCESS MVP>

message
I have an application which allows two of four shifts
each
to enter data based on which shift they belong to, day
or
night.
'
There are two drop down boxes allowing the imput
of
the
shift value represented at the time. cbo1 =
DayShift
and
cbo2 = NightShift

The first shift begins at 7:00 AM with the second shift
beginning at 7:00PM. Each shift consists of 12 hours.
The
application has a main form that swaps out sub-
forms
for
each aspect of the shift's assignments.

Currently I have the sub-forms opening in the "OnLoad"
event to acLastRec when they are called/swapped. What
I'd
like to do is have the sub-form look to see if either or
both of the shift (cbo1 or cbo2) controls have a value
or
not, if cbo1 has a value and cbo2 does not, open to
acLastRec. If both cbo1 and cbo2 already have a value do
not open to acLastRec, open to acNewRec, which
would
be
a
new day/date since both shifts have already completed
data
entry for the previous day/date and it's now a new day
and
shift.

Is this possible? How???

Thanks,...


.



.


.
 
I'm guessing that you're using A97; although I haven't worked with it, the
fact that you're getting an error on the .AddNew statement suggests that you
may be using a version of ACCESS that doesn't have this feature.

So, let's try changing the code to the following:

If Len(Me.cboDayShift.Value & "") <> 0 And _
Len(Me.cboNigthShift.Value) <> 0 Then _
DoCmd.RunCommand acCmdRecordsGoToNew

Note that you don't need the EndIf that is in your code.

--
Ken Snell
<MS ACCESS MVP>


Russ said:
Ken:

Here is the code:

If Len(Me.cboDayShift.Value & "") <> 0 And Len
(Me.cboNigthShift.Value) <> 0 Then _
Me.Recordset.AddNew
End If

The error generated targets the "Me.Recordset.AddNew" part
of the code in both instances with the "Method Or Data
Member Not Found" error.

This may help in the debugging.

Thanks,....

-----Original Message-----
Do you get the same error in both situations? Or different error for main
form and for subform? Perhaps you can post the code from both modules?

--
Ken Snell
<MS ACCESS MVP>

Ken:

Both, at times at Main Form's module level, at others at
the Sub-Form module level.

Thanks,...


-----Original Message-----
You didn't state whether the code is running in the main
form's module or in
the subform's module. Need to know this before I can
debug further.

--
Ken Snell
<MS ACCESS MVP>

message
Ken:

I keep getting the error: "Method Or Data Member Not
Found" after I plugged the code as you stated in the
sub-
form.

Since I'm new at this, can you assist further?

Thanks,



-----Original Message-----
In your code, after you load the subform, put this code
snippet (change
names to your actual names; code not tested) -- note
that
this code assumes
that you're running code in the subform; if it's in the
main form, it'll
need to be a bit different:

If Len(Me.cbo1.Value & "") <> 0 And Len (Me.cbo2.Value)
<>
0 Then _
Me.Recordset.AddNew

If the code is running in the main form, then the code
snippet would be
similar to this:

If Len(Me.Subform!cbo1.Value & "") <> 0 And _
Len(Me.Subform!cbo2.Value) <> 0 Then _
Me.Subform.Form.Recordset.AddNew

(where Subform is the name of the subform control [ the
control on the main
form that holds the subform ] ).


--
Ken Snell
<MS ACCESS MVP>

message
I have an application which allows two of four shifts
each
to enter data based on which shift they belong to,
day
or
night.
'
There are two drop down boxes allowing the imput of
the
shift value represented at the time. cbo1 = DayShift
and
cbo2 = NightShift

The first shift begins at 7:00 AM with the second
shift
beginning at 7:00PM. Each shift consists of 12 hours.
The
application has a main form that swaps out sub- forms
for
each aspect of the shift's assignments.

Currently I have the sub-forms opening in
the "OnLoad"
event to acLastRec when they are called/swapped. What
I'd
like to do is have the sub-form look to see if
either or
both of the shift (cbo1 or cbo2) controls have a
value
or
not, if cbo1 has a value and cbo2 does not, open to
acLastRec. If both cbo1 and cbo2 already have a
value do
not open to acLastRec, open to acNewRec, which would
be
a
new day/date since both shifts have already completed
data
entry for the previous day/date and it's now a new
day
and
shift.

Is this possible? How???

Thanks,...


.



.


.
 
Back
Top