UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Open Form From Another Form With Filtering, Access 2016    
 
   
jotoya
post Jun 17 2019, 03:56 PM
Post#1



Posts: 137
Joined: 17-May 16



Hi -

I have a button on my Main Menu/Switchboard form which opens another form based on the username. The form that it opens contains a textbox with the user's name. So let's say John Doe has 3 records he has completed. When John clicks the button from the main menu form, this secondary form opens and should only show those 3 records.

Here is the cmdButton code I have to accomplish the above and it uses a simple string filter for my WHERE clause:

CODE
Private Sub SpecificEntriesButton_Click()
Dim FLTR As String
Dim JD As String

JD = "John Doe"

Select Case Environ(Username)
    Case Is = 123456
        FLTR = "[Observer] = '" & JD & "'"
End Select
        
DoCmd.OpenForm "frmForm", , , FLTR
End Sub


I also added a customized set of nav buttons to include a record counter so I can turn off the nav bar on the form. Here's the code (resides in the OnCurrent event) and it works just fine, *BUT*, when the form loads, my record counter reads "record 1 of 1" rather than reading "record 1 of 3". Now, if I add DoCmd.GoToRecord , , acLast to the form's load event, it does just fine (other than sending me to record 3 of 3) but, it "solves" the problem - per se.

The weird thing is, if I activate the form's nav bar - no problem. My custom record counter now works fine at it shows record 1 of 3. If I turn the form's nav bar off, I'm back to square one. iconfused.gif

CODE
On Error Resume Next
    If Me.CurrentRecord = 1 Then
        Me.GoToPrevButton.Enabled = False
        Me.GoToFirstButton.Enabled = False
    Else
        Me.GoToPrevButton.Enabled = True
        Me.GoToFirstButton.Enabled = True
    End If
''''''''''''''''''''''''''''''''''''''''
    If Me.CurrentRecord = Me.Recordset.RecordCount Then
        Me.GoToLastButton.Enabled = False
    Else
        Me.GoToLastButton.Enabled = True
    End If
''''''''''''''''''''''''''''''''''''''''
    If Me.CurrentRecord >= Me.Recordset.RecordCount Then
        Me.GoToNextButton.Enabled = False
    Else
        Me.GoToNextButton.Enabled = True
    End If
''''''''''''''''''''''''''''''''''''''''
    If Me.NewRecord Then
        Me.NewRecButton.Enabled = False
        Me.GoToLastButton.Enabled = False
    Else
        Me.NewRecButton.Enabled = True
        Me.GoToLastButton.Enabled = True
    End If
''''''''''''''''''''''''''''''''''''''''
    If Me.NewRecord Then
        Me.RecordCounterlbl.Caption = "New Entry"
    Else
        Me.RecordCounterlbl.Caption = _
         "Entry " & Me.CurrentRecord & " of " & Me.Recordset.RecordCount
    End If


Thank you much for any suggestions/guidance.
Go to the top of the page
 
theDBguy
post Jun 17 2019, 04:23 PM
Post#2


Access Wiki and Forums Moderator
Posts: 75,713
Joined: 19-June 07
From: SunnySandyEggo


Hi. I guess the obvious workaround is to use acLast and then followed by acFirst.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
jotoya
post Jun 17 2019, 10:21 PM
Post#3



Posts: 137
Joined: 17-May 16



Hey!! DBguy! how are you sir?!

Thanks for the reply. Believe it or not, I had actually already tried your suggestion to no avail before I posted It doesn't seem to want to "obey" the DoCmd.GoToRecord , , acFirst line following the DoCmd.GoToRecord , , acLast
Go to the top of the page
 
theDBguy
post Jun 17 2019, 10:57 PM
Post#4


Access Wiki and Forums Moderator
Posts: 75,713
Joined: 19-June 07
From: SunnySandyEggo


Hi. Take a look at this navigation demo and see if there's anything in it you can use or learn from.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
jotoya
post Jun 17 2019, 11:00 PM
Post#5



Posts: 137
Joined: 17-May 16



Sure will DBguy...thanks so much!!! hat_tip.gif
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    18th July 2019 - 01:46 AM