Need equivalent code in 2000 access

G

Guest

I have a 2000 database I recently converted to access 2003. A programmer made
some changes to one of the data entry forms. I have a customer who can only
run access 2000 so I converted the 2003 database back to 2000 and everything
runs perfectly except the form that contains the new 2003 code. Does anyone
know what the code would be in 2000 to accomplish what this 2003 sub is doing?

Private Sub ShowSfm()
On Error Resume Next

Me!sfmWorkspace1.Visible = True
Me!sfmWorkspace1.SetFocus

DoCmd.GoToRecord Record:=acNewRec
Dim y As Variant
y = Me!lstService.Column(0)
Me![Forms]![performanceentry_sub]![ExamID].SetFocus
DoCmd.FindRecord y, , True, , True

Dim continue As Boolean
continue = True
While continue
If Not (Me![Forms]![performanceentry_sub]![StudentID] =
Me!cboStudent.Column(0)) Then
continue = False
Else
DoCmd.FindNext
End If
Wend

End Sub

Thanks
 
R

Rob Oldfield

Currently, it looks to me like a badly written piece of garbage that anyone
earning any cash for writing should be embarassed about. Sack them. Or
send them on a course.

What do you want it to do?
 
R

rkc

Stonewall said:
I have a 2000 database I recently converted to access 2003. A programmer made
some changes to one of the data entry forms. I have a customer who can only
run access 2000 so I converted the 2003 database back to 2000 and everything
runs perfectly except the form that contains the new 2003 code. Does anyone
know what the code would be in 2000 to accomplish what this 2003 sub is doing?

Private Sub ShowSfm()
On Error Resume Next

Me!sfmWorkspace1.Visible = True
Me!sfmWorkspace1.SetFocus

DoCmd.GoToRecord Record:=acNewRec
Dim y As Variant
y = Me!lstService.Column(0)
Me![Forms]![performanceentry_sub]![ExamID].SetFocus
DoCmd.FindRecord y, , True, , True

Dim continue As Boolean
continue = True
While continue
If Not (Me![Forms]![performanceentry_sub]![StudentID] =
Me!cboStudent.Column(0)) Then
continue = False
Else
DoCmd.FindNext
End If
Wend

End Sub

I can't sort out what's what with the forms in all that, but I would
consider simply using a recordset clone and the FindLast method instead
of all that docmd nonsense. There's a runtime error waiting to happen if
the last record meets the criteria.
 
G

Guest

When the user clicks on an item from a list on the Main form, the code below
is supposed to show all the records related to the item and the student in
the subform.
I guess I should fire the programmer, huh? I had never seen this before
either but I thought it might be some new technique in 2003. How do I fix it?

rkc said:
Stonewall said:
I have a 2000 database I recently converted to access 2003. A programmer made
some changes to one of the data entry forms. I have a customer who can only
run access 2000 so I converted the 2003 database back to 2000 and everything
runs perfectly except the form that contains the new 2003 code. Does anyone
know what the code would be in 2000 to accomplish what this 2003 sub is doing?

Private Sub ShowSfm()
On Error Resume Next

Me!sfmWorkspace1.Visible = True
Me!sfmWorkspace1.SetFocus

DoCmd.GoToRecord Record:=acNewRec
Dim y As Variant
y = Me!lstService.Column(0)
Me![Forms]![performanceentry_sub]![ExamID].SetFocus
DoCmd.FindRecord y, , True, , True

Dim continue As Boolean
continue = True
While continue
If Not (Me![Forms]![performanceentry_sub]![StudentID] =
Me!cboStudent.Column(0)) Then
continue = False
Else
DoCmd.FindNext
End If
Wend

End Sub

I can't sort out what's what with the forms in all that, but I would
consider simply using a recordset clone and the FindLast method instead
of all that docmd nonsense. There's a runtime error waiting to happen if
the last record meets the criteria.
 
R

rkc

Stonewall said:
When the user clicks on an item from a list on the Main form, the code below
is supposed to show all the records related to the item and the student in
the subform.
I guess I should fire the programmer, huh? I had never seen this before
either but I thought it might be some new technique in 2003. How do I fix it?

:

Stonewall said:
I have a 2000 database I recently converted to access 2003. A programmer made
some changes to one of the data entry forms. I have a customer who can only
run access 2000 so I converted the 2003 database back to 2000 and everything
runs perfectly except the form that contains the new 2003 code. Does anyone
know what the code would be in 2000 to accomplish what this 2003 sub is doing?

Private Sub ShowSfm()
On Error Resume Next

Me!sfmWorkspace1.Visible = True
Me!sfmWorkspace1.SetFocus

DoCmd.GoToRecord Record:=acNewRec
Dim y As Variant
y = Me!lstService.Column(0)
Me![Forms]![performanceentry_sub]![ExamID].SetFocus
DoCmd.FindRecord y, , True, , True

Dim continue As Boolean
continue = True
While continue
If Not (Me![Forms]![performanceentry_sub]![StudentID] =
Me!cboStudent.Column(0)) Then
continue = False
Else
DoCmd.FindNext
End If
Wend

End Sub

I can't sort out what's what with the forms in all that, but I would
consider simply using a recordset clone and the FindLast method instead
of all that docmd nonsense. There's a runtime error waiting to happen if
the last record meets the criteria.

O.K. I didn't pick that up looking at the code you posted. Looks to me
like it just loops to the last matching record. You say that works the
way you expect it to in Access 2003?

Why don't you just base the subform's recordsource on a query that
uses the item and studentid as criteria and requery the subform?
 
M

MacDermott

Sorry to be jumping in late here, but isn't that what LinkMasterFields and
LinkChildFields are about?


rkc said:
Stonewall said:
When the user clicks on an item from a list on the Main form, the code below
is supposed to show all the records related to the item and the student in
the subform.
I guess I should fire the programmer, huh? I had never seen this before
either but I thought it might be some new technique in 2003. How do I fix it?

:

Stonewall wrote:

I have a 2000 database I recently converted to access 2003. A programmer made
some changes to one of the data entry forms. I have a customer who can only
run access 2000 so I converted the 2003 database back to 2000 and everything
runs perfectly except the form that contains the new 2003 code. Does anyone
know what the code would be in 2000 to accomplish what this 2003 sub is doing?

Private Sub ShowSfm()
On Error Resume Next

Me!sfmWorkspace1.Visible = True
Me!sfmWorkspace1.SetFocus

DoCmd.GoToRecord Record:=acNewRec
Dim y As Variant
y = Me!lstService.Column(0)
Me![Forms]![performanceentry_sub]![ExamID].SetFocus
DoCmd.FindRecord y, , True, , True

Dim continue As Boolean
continue = True
While continue
If Not (Me![Forms]![performanceentry_sub]![StudentID] =
Me!cboStudent.Column(0)) Then
continue = False
Else
DoCmd.FindNext
End If
Wend

End Sub

I can't sort out what's what with the forms in all that, but I would
consider simply using a recordset clone and the FindLast method instead
of all that docmd nonsense. There's a runtime error waiting to happen if
the last record meets the criteria.

O.K. I didn't pick that up looking at the code you posted. Looks to me
like it just loops to the last matching record. You say that works the
way you expect it to in Access 2003?

Why don't you just base the subform's recordsource on a query that
uses the item and studentid as criteria and requery the subform?
 
R

rkc

MacDermott said:
Sorry to be jumping in late here, but isn't that what LinkMasterFields and
LinkChildFields are about?

Sure, but could you tell by the question whether the main form was bound
to a record source or not? I wasn't even sure that the invisible form
was a subform.
 
M

MacDermott

It's your choice how you see it.

Perhaps you'd rather I'd simply said that in my experience, the main form
does not have to be bound to a recordsource; you can put the name of an
unbound control in the LinkMasterFields property of the subform control.

If you looked far enough back in the archives, you might find the post where
I opined that the control on the main form must be bound; IIRC, I was simply
told I was wrong.

OTOH, why use a subform on an unbound main form at all?
I would expect better performance from a continuous form, using the header
and footer to hold the controls which would have been on the main form.

- Turtle
 
R

rkc

MacDermott said:
It's your choice how you see it.

Perhaps you'd rather I'd simply said that in my experience, the main form
does not have to be bound to a recordsource; you can put the name of an
unbound control in the LinkMasterFields property of the subform control.

Actually I would have prefered that, but it's your choice how you choose
to reply.

Now I have to go give it a try because I have learned something new.
Just as you did back in the archives. Thanks for getting around to
actually pointing it out.
 

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

Similar Threads


Top