Thanks again. I have a few questions, if I may. I have a way to go with my
understanding of VBA, procedures, modules, subs, functions, etc. I know
that I can place a general procedure within a form and call it from
elsewhere within the form (Call MyProcedure). I take it that a standard
module works similarly, except that it is called by a different method (Call
Modules!MyModule!IndexNumber, or something like that). The thing I can't
quite figure from Help is the index number thing. I would expect to call
the procedure by name. Maybe the index number would be clear if I was to
actually create a standard module, but for now I have bounced around in Help
without getting a clear picture. I believe that a public procedure
within a
form can be called from another form in that database, but I don't know
if
that form needs to be open. I can see that one clear advantage of a
standard module is that it can be exported to another database. That could
save a lot of time. I could make a kind of library database.
Back to your code, I can't quite figure out where you defined strRecordName
and frmName. I see that they are mentioned along with the name of the
function. Are they part of the built-in VBA vocabulary? In the
concatenated string: RecXofY = "New " & strRecordName, what will appear in
place of strRecordName?
My best guess is that the function returns a string, and that RecXofY refers
to the function itself. Calling the function from a form calls one of
the
two resulting text strings. Am I anywhere near being on track? Finally,
how does a sub differ from a function? I know this is a lot of
questions.
Any guidance you have time to offer would be very much appreciated.
Arvin Meyer said:
Thanks. When I was getting started I often took the code I was
offered
verbatim. If it worked I asked no questions. Now that I am acquiring
some
experience I look back on some of my earlier efforts and wondering why I
did
something a particular way. I appreciate the response and the new
information.
As with much of the way Access (and all of Windows, for that matter)
works,
there is often many ways to accomplish a task. I use a variation of the
code
I posted in a standard module so that it can be called from all forms:
Public Function RecXofY(frmName As Form, strRecordName As String) As
String
Dim rst As DAO.Recordset
Set rst = frmName.RecordsetClone
On Error Resume Next
rst.Bookmark = frmName.Bookmark
If Err Then
RecXofY = "New " & strRecordName
Else
RecXofY = strRecordName & " " & rst.AbsolutePosition + 1 & " of
" &
rst.RecordCount
End If
rst.Close
Set rst = Nothing
End Function
As a slightly different method, but very similar to the one you
offered,
this one can be used directly in the property sheet:
=IIf([NewRecord],"New Record","Record " & [CurrentRecord] & " of " &
Count(*))
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access