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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Form and Link Criteria Not Working 1

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
Hi,

I have a form that is used to enter absence records, fairly basic but does the job for that.

When the form loads it loads to a new record, when an employee is chosen it checks the database to find all open records, these are then displayed in a sub form, this works fine.

If a record is found a msgbox popups up and asks the inputter if they wish to edit an existing record, if they say yes the main form is cleared and they can then choose a record from the sub form, this is where the problem lies, the sub form shows the correct existing record for the employee but when it loads the data into the main form it goes to the first record in the table not the record which was selected in the sub form.

example, agent 1 has existing record, but agent2 record is loaded

I have stepped through the link criteria and it says it is finding the correct id, but it loads a different ID into the form.

Here is the coding for the sub form click button

Code:
On Error GoTo Err_cmdedit_Click

    Dim stDocName, stdocname2 As String
    Dim stlinkcriteria As String

    'stDocName = "frmLineManagerListing"
    stlinkcriteria = Me.SicknessReference
    
    stdocname2 = "frmAbsenceLogging"
    DoCmd.OpenForm stdocname2, , , stlinkcriteria
Exit_cmdedit_Click:
    Exit Sub

Err_cmdedit_Click:
    MsgBox Err.Description
    Resume Exit_cmdedit_Click
here is the code for on load event of the main form, the sub form should be sending the data back to the main form if they wish to edit the record, but it doesn't it always puts the first record in the table, not the selected record.

Code:
DoCmd.Maximize
 With Me![frmSubAbsencesbyAgent].Form
        .Visible = (.RecordsetClone.RecordCount > 0)
    End With

the main form is bound to a table.

Hope this is enough info, if not let me know.



Hope this is of use, Rob.[yoda]
 
Replace this:
stlinkcriteria = Me.SicknessReference
with something like this:
stlinkcriteria = "[Name of SicknessReference field]=" & Me.SicknessReference

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
that worked so simple when its in front of you



Hope this is of use, Rob.[yoda]
 
[tt]Dim stDocName, stdocname2 As String
[/tt]
You do know that only stdocname2 is a String, stDocName is a Variant, not a string.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top