Help needed to modify code (1 Viewer)

WebFaktor

Registered User.
Local time
Today, 17:41
Joined
May 12, 2001
Messages
81
Hi,

Below I have two code samples taken from a record editing form. "Record n of n" code is an on current event proceedure for the form. The "Add new record to table" code occurs per a user choice made by clicking a button.

PROBLEM: when a new record is created in the table, I'd like for the "Record n of n" code to state "NEW RECORD" instead of "Record 1 of 9" for example.

Thank you in advance
_________________________________________
"Record n of n" code
__________________________________________
Private Sub Form_Current()
If Me.NewRecord Then
Me!lblNavigate = "New Record"
Else
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me!lblNavigate = "Record " & Me.CurrentRecord & " of " & Me.Recordset.RecordCount
End With
End If
End Sub

__________________________________________
"Add new record to table" code
__________________________________________
Private Sub Command162_Click()
Dim rstMyRecordset As Recordset
Set rstMyRecordset = CurrentDb.OpenRecordset("Catalog_EFG_DataEntry", dbOpenDynaset)
rstMyRecordset.AddNew
rstMyRecordset.Fields("Subject_Number") = Me.[Subject_Number]
rstMyRecordset.Fields("Subject_Name") = Me.[Subject_Name]
rstMyRecordset.Fields("Document_Name") = Me.[Document_Name]
rstMyRecordset.Update
Set rstMyRecordset = Nothing 'Free Memory
End Sub
 

pdx_man

Just trying to help
Local time
Today, 09:41
Joined
Jan 23, 2001
Messages
1,347
Couple of questions ...

What version of Access? Assuming 97 ...

Is your form's RecordSource Catalog_EFG_DataEntry?

Does this Record n of n code work? I believe you should have .RecordCount instead of Me.Recordset.RecordCount

Is lblNavigate a TextLabel or TextBox?
If Label, include the .Caption when assigning a value to change the display.

I will check back later.

[This message has been edited by pdx_man (edited 05-30-2002).]
 

WebFaktor

Registered User.
Local time
Today, 17:41
Joined
May 12, 2001
Messages
81
_Q:What version of Access? Assuming 97 ...
_ _A:Access 2000

_Q:Is your form's RecordSource Catalog_EFG_DataEntry?
_ _A:NO (The data edit form itself is working off of a query entitled "Catalog_Gb_EditDataDeveloping qry" that utilizes/joins 2 tables, with the "Catalog_EFG_DataEntry" table being one and "Catalog_EFG_DocDirectionsRef" table being the other.)

_Q
oes this Record n of n code work? I believe you should have .RecordCount instead of Me.Recordset.RecordCount
_ _A:YES (It does effictively tell what record of a total number of records you're viewing/editing)

_Q:Is lblNavigate a TextLabel or TextBox?
If Label, include the .Caption when assigning a value to change the display.
_ _A:It's a TextBox that is referenced by the form in which it's contained by the On Current property event. (sorry, I can now see how that may have been confusing)

Thanks!
 

pdx_man

Just trying to help
Local time
Today, 09:41
Joined
Jan 23, 2001
Messages
1,347
So then, the Catalog_EFG_DocDirectionsRef table contains the Subject_Number,Subject_Name and Document_Name fields? I assume so, since that would then create a duplicate instance, unless these fields are not bound to any field from you query and you are updating this info.

I'm just not sure how you are doing your entry of a new record. Do you navigate to a record on the form and then input info into these unbound fields, then click the Add Record button?

If so, use the OnChange event to change the value of lblNavigate.
 

WebFaktor

Registered User.
Local time
Today, 17:41
Joined
May 12, 2001
Messages
81
pdx_man

Would you mind were I to send you a copy of this db and direct you specifically to the form/code?

Michael
 

pdx_man

Just trying to help
Local time
Today, 09:41
Joined
Jan 23, 2001
Messages
1,347
Sure. Save it as Access97, though.

[This message has been edited by pdx_man (edited 05-30-2002).]
 

Users who are viewing this thread

Top Bottom