Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / January 2005

Tip: Looking for answers? Try searching our database.

form load operation isnt working

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
reservedbcreater - 27 Jan 2005 18:48 GMT
Private Sub Form_Load()

Dim strNextNumber As String

strNextNumber = Nz(DMax("ID", "General Housing Survey"), 0) + 1

strNextNumber = Me.ID

End Sub

?????
i want it to read the General Housing Table ID field and get the highest
number and then increment it by 1 and then fill in the ID field
automatically on the form with the new number opon it opening
reservedbcreater - 27 Jan 2005 19:00 GMT
this doesnt work either

Private Sub Form_Load()

Dim strDocName As String
Dim strNextNumber As String

strDocName = "General Housing Survey"
strNextNumber = Nz(DMax("ID", "General Housing Survey"), 0) + 1

strNextNumber = Me.ID
Forms(strDocName)!ID = strNextNumber
Marshall Barton - 27 Jan 2005 19:03 GMT
>Private Sub Form_Load()
>
[quoted text clipped - 10 lines]
>number and then increment it by 1 and then fill in the ID field
>automatically on the form with the new number opon it opening

You have the second line backwards.  It should be:

    Me.ID = strNextNumber

BUT, you do NOT want to do this unless you are certain that
the form is on a new record.  It would be more than a little
disasterous to do that to an existing record.

Signature

Marsh
MVP [MS Access]

reservedbcreater - 27 Jan 2005 19:36 GMT
thank you it worked marshall
Joe Holzhauer - 27 Jan 2005 19:05 GMT
See responses inline below:

> Private Sub Form_Load()
>
> Dim strNextNumber As String
Are you sure you want this to be a string variable?  If you're numerically
incrementing it, it might make more sense if it were a Long.  What data type
is your ID field within the table?

> strNextNumber = Nz(DMax("ID", "General Housing Survey"), 0) + 1
I honestly don't know if it makes a difference in this context, but usually
when there are spaces within an object name, you should enclose the name in
brackets:
...DMax("ID", "[General Housing Survey]")...

> strNextNumber = Me.ID
I think you want this to be reversed, as in:
Me.ID = strNextNumber
otherwise, you're just overwriting your variable with the contents of the ID
field.

> End Sub
>
> ?????
> i want it to read the General Housing Table ID field and get the highest
> number and then increment it by 1 and then fill in the ID field
> automatically on the form with the new number opon it opening

Hope this helps,
Joe
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.