Record navigation

chrisguk

Registered User.
Local time
Today, 03:33
Joined
Mar 9, 2011
Messages
148
Hi,

I have two forms:

frmsites = Main form
frmlog = other form

I have a button located on "frmsites" to open "frmlog". The code behind the button is as follows:

Code:
Private Sub new_query_Click()
If intAccessLevel < 3 Then
    MsgBox "You do not have access rights to create a new query", vbExclamation + vbOKOnly, "Acces Denied"
    Exit Sub
End If
 
Dim stDocName As String
Dim stLinkCriteria As String
 
    stDocName = "frmlog"
    DoCmd.OpenForm stDocName, , , , acFormEdit
    Forms![frmlog]![sitesid] = Forms![frmsites]![sitesid]
    DoCmd.Close acForm, "frmsites", acSaveYes
    
End Sub

The tbls are linked as follows:

tblsites = PK sitesid
tbllog = PK logid, FK sitesid

Now when I open the "frmlog" in the field named logid it is an autonumber. The sitesid field displays the site number that appeared on the form I have just navigated away from namely "frmsites".

So this all works well.

The issue I have is when I want to move through the existing entries within "frmlog" it displays other siteid's as well when it should be locked only to the queries generated on the siteid I navigated away from.

For example:

frmsites - sitesid = 1121
open frmlog - displays logid = 15 and displays sitesid = 1121
start clicking through the records and the sitesid number changes to others that are in the database.

Pulling my hair out :) Can anyone help?
 
I see nothing in your code that would limit the records the frmlog form can view.
 
As Allan pointed out, you've done nothing to limit the records displayed, you've only moved to a record that meets your criteria.

To only display records that fit your criteria, you need to use that criteria to filter your form's records.

Linq ;0)>
 
As Allan pointed out, you've done nothing to limit the records displayed, you've only moved to a record that meets your criteria.

To only display records that fit your criteria, you need to use that criteria to filter your form's records.

Linq ;0)>

are you able to give me a simple example of how this is done?
 

Users who are viewing this thread

Back
Top Bottom