me.currentrecord not tue

G

Guest

Hello
I have builded a msg triggered from few events, to track, while debugging, on which record I’m when performing some operation
The msg is
MsgBox chi & "/new_record? " & Me.NewRecord & " record#: " & Me.CurrentRecord & " of " & Me.Recordset.RecordCoun

This msg is showed when the beforeupdate event is called so that I can see which record would been updated
And it is also triggered by clicking a command button on the form

The cycle property is settled to current record. So when the record is updated I’m still seeing it. If I click the command button after the record is been updated, what is different is that Me.NewRecord switched to “falseâ€
Fine
Also closing the form calls the msg
In this case I need to know why the current record is “0†while I suppose it should be 1..or 2…or whatever, depending on what record I was in that moment

Thank
Rocco
 
M

Mark A. Sam

Rocco,

It is probably becuase the Unload event occurs before the Close event and
thus the no data to reference. (Just my thinking)
When you close a form, the following events occur in this order:

Unload Þ Deactivate Þ Close

Try moving the code to the Unload event.


rocco said:
Hello,
I have builded a msg triggered from few events, to track, while debugging,
on which record I'm when performing some operation.
The msg is:
MsgBox chi & "/new_record? " & Me.NewRecord & " record#: " &
Me.CurrentRecord & " of " & Me.Recordset.RecordCount
This msg is showed when the beforeupdate event is called so that I can see
which record would been updated.
And it is also triggered by clicking a command button on the form.

The cycle property is settled to current record. So when the record is
updated I'm still seeing it. If I click the command button after the record
is been updated, what is different is that Me.NewRecord switched to "false".
Fine.
Also closing the form calls the msg.
In this case I need to know why the current record is "0" while I suppose
it should be 1..or 2.or whatever, depending on what record I was in that
moment.
 
M

Mark A. Sam

Rocco,

I think I undestand this. You don't want there to be a record in the
subtable if it isn't completed to a certain extent. I will suggest a better
method than you are using. This is not how I would do it, but it should
work better for you than what you are attempting. I don't know what your
expeience level is either so you may have some learnign to do.

Make a copy of the subform and remove the Reocordsource of the form as well
as the ControlSource for each field. Also make the form a popup. Put a
button on the mainform to open the new popup form. ou will have a
commandline that looks like this:


DoCmd.OpenForm "myForm", , , , , acDialog, [myChildfield]
[mySubform].Requery


[myChildField] is the name of the ChildLink field of the subform. It will
be passed to the popup form as a varialble that you can use to assign the
ChildLink field of the popup form.

On the popup form, set the default value for the textbox, [myChildLink], or
whatever it is called to the word, "OpenArgs", without quotes. that will
automatically relate the subform record to the main table. You don't need
openargs to do this. You can also set the default value to
Forms![myMainForm]![myChildLink] as well as other textboxes on the popup.
For the fields that the combobox populares, you can place substituted
texxboxes and make them invisible. Use the defualt value on the popup form
to populate them.

There should be an Ok button and a Cancel Button on the popup. The Cancel
button will simply close the form. The Ok button should go through and
validate that the necessary textboxes are populated, then close the form.

If the necessary textboxes are populated on the Popup, then you can either
populate the Subtable using DAO or right from the Ok button click event like
this:

Forms![myMainform].[mySubform],Form![textbox1] = [textbox1]
Forms![myMainform].[mySubform],Form![textbox2] = [textbox2]
Forms![myMainform].[mySubform],Form![textbox3] = [textbox3]

Etc.

Substitute your Main form name for [myMainForm] and your subform name for
[mySubform]. as well as your textbox names.

I hope that all makes sense to you.

God Bless,

Mark A. Sam






rocco said:
thanks,
i tried moving on the unload event but still the me.currentrecord gives me
"0" of "1'" while it should be "1" of "1".
i'll try to explain wgy all this mess i have builded.
The form that shows the record is actually a subform placed on the first
page of a tab control. And i have other four forms each on a different page
of this tabcontrol.
On the main form there is a combo box where the user can choose for which
client he is going to enter or edit records.
Each subform has a text box whose value is automatically settled when
user choose a name from the combobox on the main page. Let's say that after
choosing a name, the user close the main form. The before-update event for
the form underlying the subform happens, recording data into the table. But
since i dont' want to record records with just only the name of the client
and no other info, I use the close method for the form underlying the
subform to elete this "quite" blank record. The before update event makes a
boolean variable to became "true".
the close method read the value of this variable, if it is "true" it use
the me.recordset.delete; if the value is "false" - due to the fact that an
update for that record is not been done - I use a symple me.undo.
Now. On closing I have checked that the value of the variable is "true"
but it says "no current record" and obviously it gives me an error on the
line me.recordset.delete. Action that it can't perform
 

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

Top