Multiple criteria to open a FORM

radek225

Registered User.
Local time
Today, 15:14
Joined
Apr 4, 2013
Messages
307
How to open FORM which has "inner join" in source?

Code:
...
Dim idRS As DAO.Recordset, ShowIdentity
    strSQL = "INSERT INTO tblZlecenia (id_zlecenia_info, DataPrzyjecia) VALUES ('" & _
                                        ostateczne & "', " & _
                                        Format(Date, "\#mm\/dd\/yyyy\#") & ")"
    CurrentDb.Execute strSQL, dbFailOnError
        
    Set idRS = CurrentDB.OpenRecordset("SELECT @@IDENTITY AS LastID;")
    ShowIdentity = idRS!LastID
    idRS.Close

Dim idRS1 As DAO.Recordset, ShowIdentity1
    strSQL = "INSERT INTO tblOffset (id_zlecenia) VALUES ('" zlecenie_najwieksze "')"
    CurrentDb.Execute strSQL, dbFailOnError
        
    Set idRS1 = CurrentDB.OpenRecordset("SELECT @@IDENTITY AS LastID;")
    ShowIdentity1 = idRS1!LastID
    idRS1.Close
    
    DoCmd.OpenForm "Formularz2", WhereCondition [COLOR="Red"]there must be [id_zlecenia] = showIdentity and [id_tblOffset] = showIdentity1[/COLOR]
 
You have it almost there, simply use it correctly. Show the recordsource of the Form.
 
Code:
SELECT tblZlecenia.*, tblOffset.raport, tblOffset.CieteNaSztuki, tblOffset.edycja_list, tblOffset.Bigowane, tblOffset.Falcowane, tblOffset.NacinaneNaArkuszu, tblOffset.NacinaneOdSpodu, tblOffset.Sztancowanie, tblOffset.Tloczenie, tblOffset.KlejenieWBloki, tblOffset.ZszywkiProste, tblOffset.ZszywkiZUszkiem, tblOffset.Opis, tblOffset.ID_RodzajZlecenia, tblOffset.ID_Zlecenia AS ID_Zlecenia_tblOffset, tblOffset.Id_tblOffset, tblOffset.Plyty_archiwizowac, tblOffset.Klicze_archiwizowac, tblOffset.oprawa, tblOffset.plyty_sa, tblOffset.klisze_sa, tblOffset.Uwagi_z_produkcji, tblOffset.Skrocony_obieg, tblOffset.Klisze_na_lakier_sa, tblOffset.Hotstamping, tblOffset.Ilosc_Kompletow, tblOffset.DziedziczonePo, tblOffset.DziedziczonePoBiuro FROM tblZlecenia INNER JOIN tblOffset ON tblZlecenia.ID_Zlecenia = tblOffset.ID_Zlecenia;
 
So what you are trying to do here? Explain the logical process flow.
 
I just try to open this form after INSERT INTO. Yesterday You gave me a code that allows me open a form a moment after INSERT INTO and It works, but when I writing an example in post I forgot that my FORM doesn't have only one source (not from one table but two tables). Your code works great - if FORM has only one source. Now You see I have "inner join" in my source. So I thought that should use the same way with second table of my source to open form correctly and open form using not one but two criteria in WhereCondition. But now I have a problem with correctly writing "WhereCondition"
 
If you are opening a Form that will have ONE to MANY relationship and you want to open on a particular record of the Many side of the table, use only the second ID. Or open the form using the One side and then filter the subform secondly.
 

Users who are viewing this thread

Back
Top Bottom