My apologies for the length.
You'll find I don't post a lot, but the few I do post have a lot of what I hope is useful information.
In two parts:
@Seth
Actually, the form object does have a current record property: Form.CurrentRecord Property (Access). And the recordset object doesn't list Current Record as being one of its properties.
Seth what are you trying to state here in post #3?
In the first part you tell us something that is already known and is what OP is trying to use. Then in the second part you go off on a tangent with recordsets which OP doesn't mention.
Also in post #5, I want to point out that you are using the me-dot-ctrlname... instead of the me-bang-ctrlname. Not that there's anything wrong between the two conventions in
as we're trouble shooting and is a good way to double check a control name. However, an alternative that most people are not aware of when using the me-bang-ctrlname method is that when you type the bang "!" , the very next thing to press is, <ctrl><spacebar> - You will get a context type popup (usually starting with A_ADD), this works just like a combo/listbox if you keep typing the control's name it will be eventually selected enough to press the [Tab] key or arrow/mouse to the correct control. Ah, this is why all of my controls start with "z_" so that all of my controls are grouped.... for example for a control on the current form I would type "M""E""!""<ctrl><SpaceBar"[the popup opens]"z""_" as I type the last two, the first control name in the form's control collection in the list is selected.
<ctrl><spacebar> is also useful in alot of other situations as it pulls up the constants (like when opening a dynaset start you "SET" start typing, when you get to the record type <ctrl><SpaceBar>dbopen... ) My spelling is, well, very bad, and my memory slips so having this available is a great asset for me.
-x-
JHite:
(...)I'm trying to show the user the current record number by displaying it in the text box named CRNum on frmGrantLoan.
Be careful here... consider what information you are really needing to provide the user - do they need the absolute record number for the current recordset or the primary key from the current record within the recordset?
I know that makes no sense what so ever, so let me try via an example:
Consider a table where in you have an autonumber as the primary key. In a normal database, you'll often end up with the primary key and the record number not being the same (i.e.)
- [AccessRecord_#][autonumber_pk][someinfo]....
-
(1) (1) (d)
-
(2) (2) (c)
-
(3) (4) (e)
-
(4) (5) (f)
-
(5) (8) (a)
-
(6) (11) (b)
-
(7) (20) (g)
-
(8) (25) (h)
-
(...)
Notice that the first two record numbers match the primary key; however, starting at record 4, things are out of sync. Thus, if you provide the [AccessRecord_#]=8 to the user and you serch on [autonumber_pk] for (8) to find the the information in [someinfo] then you would return [AccessRecord_#]=5 and get (a) when you were expecting (h)
AND this WILL get worse if you are using a query for the form... say,
WHERE [autonumber_pk]>=5
the [AccessRecord_#]=1 is related to [autonumber_pk]=5 and your search based on this set of record number will be even more interesting. Oh my... and if the user does a sort on one of the data columns like [someinfo] the first record will be for primary key 8. Welcome to the nightmare.
The only time I pass an absolute record number to the user is when I am pulling directly from the data table, sorted in a VERY specific order for the purpose of troubleshooting. If I need to keep referring to a specific record in VBA, I'll set a bookmark as the CurrentRecord recordid is not always reliable given that I often allow the user to sort on what ever field they want and so forth.
As for why your control is not working:
As Seth and others have pointed out:
You either have the control name wrong or you are entering your VBA in the Parent form and not the Child form.
Want to test that theory?
In your event copy and paste:
msgbox parent.name
If you are in the parent form's code, without an error trap, you should get a debug dialog:
- [Microsoft Visual Basic]
-
[Run-time '2452':]
-
[The expression you entered has an invalid reference to the Parent property.]
Or you might get the name of a form you're not expecting
Just a few thoughts.
I've got to go school the kids on how to share their toys by removing the offending object from play. I don't punish one, I make them all unhappy.... it takes two (or more) to fight. I find that they tend to try to solve the issue themselves without my micromanagement. I also answer "NO" to most questions asked when I'm on the telephone or in conversation with another adult. Even if it would be something I'd normally allow... I don't get interrupted much either...
ttfn