Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-30-2002, 08:12 AM   #1
WebFaktor
Registered User
 
Join Date: May 2001
Location: Chicago
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
WebFaktor
Help needed to modify code

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

WebFaktor is offline   Reply With Quote
Old 05-30-2002, 10:56 AM   #2
pdx_man
Just trying to help
 
pdx_man's Avatar
 
Join Date: Jan 2001
Location: Portland, OR USA
Posts: 1,347
Thanks: 0
Thanked 3 Times in 3 Posts
pdx_man is on a distinguished road
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).]
pdx_man is offline   Reply With Quote
Old 05-30-2002, 11:23 AM   #3
WebFaktor
Registered User
 
Join Date: May 2001
Location: Chicago
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
WebFaktor
_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!

WebFaktor is offline   Reply With Quote
Old 05-30-2002, 11:57 AM   #4
pdx_man
Just trying to help
 
pdx_man's Avatar
 
Join Date: Jan 2001
Location: Portland, OR USA
Posts: 1,347
Thanks: 0
Thanked 3 Times in 3 Posts
pdx_man is on a distinguished road
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.
pdx_man is offline   Reply With Quote
Old 05-30-2002, 12:39 PM   #5
WebFaktor
Registered User
 
Join Date: May 2001
Location: Chicago
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
WebFaktor
pdx_man

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

Michael
WebFaktor is offline   Reply With Quote
Old 05-30-2002, 02:19 PM   #6
pdx_man
Just trying to help
 
pdx_man's Avatar
 
Join Date: Jan 2001
Location: Portland, OR USA
Posts: 1,347
Thanks: 0
Thanked 3 Times in 3 Posts
pdx_man is on a distinguished road
Sure. Save it as Access97, though.

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

pdx_man is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 07:03 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World