Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a Form in popup mode and go to Last Record (dbw_hide) 1

Status
Not open for further replies.

lmarc

Technical User
Mar 6, 2009
27
PT
Here it goes!

I desire to open a form in popup mode and goes to the last record.

This doesn't work!
Code:
Private sub form_open(cancel as integer)
 DoCmd.RunCommand acCmdRecordsGoToLast
'...neigther this
 DoCmd.GoToRecord , , acLast
So, wen the database window of Access 07 'hided', i just can't go to the LastRecord, wy? With databse windows maximized not (hide) works fine, but otherwise does not do what i want!

Give me a hint!?
regards
 
lmarc . . .

Try the [blue]On Load[/blue] event instead! ...

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
yap. already try it but nothing!

I realy dont know, i'm not an expert but.. even the navigation button seems to be stuck or something, in both ways.

I have a form and a subform, works fine in the other way (not hided) but in popup mode I dont get it :p
 
If you wanna see the file i can send the link, i have no problem with that ;)

 
lmarc . . .

Ok ... try this instead:
Code:
[blue]      Me.Recordset.MoveLast[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
AceMan ;)

I already made a search in the forum and try this to but still nothing. With that line 'Docmd.Recordset Movelast' on open event or load event just dont even open the form!

Maybe is in the module that i have to put some code to oblige to open in last record... i dont know if is that what i have to do hmmm...

 
Solved!
until now

Code:
Private Sub Form_Current()
Me.Recordset.MoveLast
DoCmd.GoToControl "Num"
End Sub

I always thought would be easy, but as i said, i'm not an expert ;)

Thankyou very mutch for your help! AceMan
 
:( run-time error 3021 no current record

yes, and is almost solved :x

EOF BOF??
 
lmarc . . .

Hold It ... Hold It! [surprise]

Be aware: the [blue]On Current[/blue] event [blue]triggers[/blue] each time you navigate to a different record! This means you'll simply go back to the last record again ... Try it! ... manually goto another record.

This can be fixed, I just want to make sure you understand this.

[blue]Your Thoughts? . . .[/blue]





See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 

To put it another way, the last record in the recordset, at this point in time, is the only record you will ever be able to go to again, with this code in place!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
hmm ok! My thoughts?
Manually i can not goto another record! i try this yes.

I realise that on open or load event:
'Me.Recordset.MoveLast
'DoCmd.Runcommand acCmdRecordodGoTOLast
'DoCmd.GotoRecord , , acLastRecord

stay the same!

So, that procedure 'Current' ok i understand! but what now..
 
lmarc said:
[blue]So, that procedure 'Current' ok i understand! but what now.. [/blue]
You can use a [blue]boolean variable[/blue] to let the code know the form was just opened. The manipulation is to only allow the current event code to execute once on open.

So in the [blue]declaration section[/blue] of the forms code module, copy/paste the following line:
Code:
[blue]Private flgCurrent As Boolean[/blue]

And the [blue]On Current[/blue] event now looks like:
Code:
[blue]   If flgCurrent = False Then
      Me.Recordset.MoveLast
      DoCmd.GoToControl "Num"
      flgCurrent = True
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
like this?
Code:
Private flgCurrent As Boolean
Option Compare Database
Private Sub Form_Current()
  If flgCurrent = False Then
      Me.Recordset.MoveLast
      DoCmd.GoToControl "Num"
      flgCurrent = True
  End If
End Sub

nop! remain the same...

I could give you more ideas if I knew more of code :p
 
lmarc . . .

AceMan has to work too, and its hard getting in a post at work.

Anyway:
Code:
[blue][b]Change:[/b]
   Private flgCurrent As Boolean
[b]To:[/b]
   [purple][b]Public[/b][/purple] flgCurrent As Boolean[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I know that ehe.. AceMen work very hard, but here is very very important your other job (joke) ;)!

So Public to be assume for all database ins't it!?

Yap, same result. run-time error 3021
Google already to find a answer but not easy. just need this to be finish with this db.

 
And this ?
Code:
Option Compare Database
Private flgCurrent As Boolean
Private Sub Form_Current()
With Me.Recordset
  If Not (flgCurrent Or .BOF Or .EOF Or Me.NewRecord) Then
    .MoveLast
    Me!Num.SetFocus
    flgCurrent = True
  End If
End With
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi phv

In this case 'Private or Public'no error, opens the form yes but aint goes to last record. Set focus to "Num" ok but can't even manualy go to previous record! hmm almost there i guess!?



Make your life an example to help development in a better world.
 
Code:
Private flgCurrent As Boolean
Option Compare Database
Private Sub Form_Current() 'on Load event is the same, and on open event no error and not popup to
With Me.Recordset
  If Not (flgCurrent Or .BOF Or .EOF) Then 'with or without Me.NewRecord 
    .MoveLast       
    'from default "Num" is the first tab
    flgCurrent = True
  End If
End With
End Sub
I want this running in popup mode clean and working, I'm trying and I will not give up ;)

Make your life an example for a better world.
 
It seems that i have to make my db with windows database visible (not hide) if i wanna to go last record. Very annoying and hard to believe that never happening before with another nerd :p. Sugestions are very apreciated!??


Make your life an example for a better world.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top