Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    ThornofSouls's Avatar
    ThornofSouls is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Sweden, Gothenburg
    Posts
    42

    Post Send data to form with query.

    Hello I have a few thing here i would like to have help with.
    Instead of sharing the code this time i thought sharing the database would be much more simple.



    There mainly three things i'm focusing now.
    1. Navigate to "Förhandsgranska" \ "Klient". (Preview\ Client) then select a test client and then click on "Visa Klient". Then a form with more details information about the client will open. To the right is a sub form i'm trying to run with a self updating query so the "Client ID" so the query only would list the records with equal client id.
    2. Navigate to "Förhandsgranska" \ "Ärende". (Preview\ Errand) then select an errand and press the "Visa" button. I'm trying to make this form work as the one with the clients.
    3. Prevent the forms which maning the errands to not save a new errand for an client id which do not exist in the database.




    Click me to download the database.

    //Thorn.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Tried to download but my home internet is too weak and blocked at work. Can you attach zipped db to post?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ThornofSouls's Avatar
    ThornofSouls is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Sweden, Gothenburg
    Posts
    42
    Sadly do the forum not support .7z files. And a .zip exceeds the forum upload limitations.

    another solution is to share the dropbox folder, in that case you can open the file from the cloud which is really nice.
    Otherwise i have to think of another solution. Then again.

  4. #4
    ThornofSouls's Avatar
    ThornofSouls is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Sweden, Gothenburg
    Posts
    42
    lol, i just solved one of the thing by deleting the form and redo it from the base structure. Otherwise the source code was identical.

    Then it is just one form to go, :P
    I'll see if i can show some pictures with the code associated to that form.
    Then, this form i'm talking about now is a sub form which is supposed to run a self-update query each time the form is opened. If it is possible that is.

    The code from the main menu:
    Code:
    Option Compare DatabasePrivate Function addCrLf(AddValue As Integer) As String
        'Convenience routine to build a concatenated string of carriage returns / line feeds
        'given a specified count
        
        Dim intCount As Integer
        Dim strReturn As String
        
        strReturn = ""
        For intCount = 1 To AddValue
            strReturn = strReturn & vbCrLf
        Next intCount
        
        addCrLf = strReturn
    End Function
    Private Sub btnDelete_Click()
        Dim strCase As String
        If MsgBox("You are about to DELETE a record >Primary Case<. " & addCrLf(2) & "Are you SURE you want to delete this record and all attached records? " & addCrLf(2) & "OBS!! An deleted record can't be undon!!", vbYesNo) = vbYes Then
            strCase = "Primärt ärende:   " & Me!txtCaseID & addCrLf(2) & " Relaterande ärenden - Före: " & addCrLf(2) & " Relaterade ärenden - Efter: " & addCrLf(2)
            Me.AllowDeletions = True
            DoCmd.RunCommand acCmdDeleteRecord
            Me.AllowDeletions = False
            MsgBox (" " & strCase & "Have been deleted!")
        End If
    End Sub
    
    
    Private Sub btnPre_Click()
        Dim CaseID As String
        CaseID = Me!txtCaseID
        
        DoCmd.Close acForm, "frmClientSummery"
        DoCmd.Close acForm, "frmMenu"
        DoCmd.OpenForm "frmCaseNEW", OpenArgs:=CaseID
    
    
    End Sub
    
    
    Private Sub cboOro_AfterUpdate()
    On Error GoTo Err_Process
    
    
        'Recive data from the form elemnts.
        Dim cboItem As String
            
        Select Case cboOro.Value
            Case 1
                Me.cboOro.BackColor = RGB(0, 0, 255)
            Case 2
            Case 3
            Case 4
            Case 5
            Case 6
        End Select
    Exit_Process:
        Exit Sub
    Err_Process:
        Resume Exit_Process
    End Sub
    
    
    Private Sub cboOro_BeforeUpdate(Cancel As Integer)
    On Error GoTo Err_Process
    
    
        'Recive data from the form elemnts.
        Dim cboItem As String
            
        Select Case cboOro.Value
            Case 1
                Me.cboOro.BackColor = RGB(0, 0, 255)
            Case 2
                Me.cboOro.BackColor = RGB(0, 0, 255)
            Case 3
                Me.cboOro.BackColor = RGB(0, 0, 255)
            Case 4
                Me.cboOro.BackColor = RGB(0, 0, 255)
            Case 5
                Me.cboOro.BackColor = RGB(0, 0, 255)
            Case 6
                Me.cboOro.BackColor = RGB(0, 0, 255)
        End Select
    Exit_Process:
        Exit Sub
    Err_Process:
        Resume Exit_Process
    End Sub
    
    
    Private Sub Form_Open(Cancel As Integer)
        Me.AllowAdditions = False
        Me.AllowEdits = False
        Me.AllowDeletions = False
    End Sub

    The code from the form:
    Code:
    Option Compare Database
    
    Private Sub btnClose_Click()
            DoCmd.Close acForm, Me.Name
            DoCmd.OpenForm "frmMenu", acNormal
    End Sub
    
    
    Private Sub btnEdit_Click()
            Me.AllowEdits = True
            Me.txtMsg1.Visible = True
    End Sub
    
    
    Private Sub btnSave_Click()
            Me.AllowEdits = False
            Me.txtMsg1.Visible = False
    End Sub
    
    
    Private Sub btnUndo_Click()
        Me.AllowAdditions = True
        Me.AllowEdits = True
                Me.txtMsg1.Visible = False
                Me.Undo
                Me.Refresh
        Me.AllowAdditions = False
        Me.AllowEdits = False
    End Sub
    
    
    Private Sub Form_Open(Cancel As Integer)
    
    
        If Nz(Me.OpenArgs) = 0 Then
        
        Else
                Me.RecordSource = "SELECT tblErrand.*, tblClients.FirstName, tblClients.LastName FROM tblClients INNER JOIN tblErrand ON tblClients.ClientID = tblErrand.ClientID WHERE (((tblErrand.ErrandID)=" & Me.OpenArgs & "));"
        End If
        
        Me.txtMsg1.Visible = False
        Me.AllowAdditions = False
        Me.AllowDeletions = False
        Me.AllowEdits = False
        
    End Sub

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What do you mean by 'self-update query'? What code would that be?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ThornofSouls's Avatar
    ThornofSouls is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Sweden, Gothenburg
    Posts
    42
    A query which will requery each time a form is opened or say a value is changed in a search filter.

    When the user browsing the existing clients it looks like this, Img1. From can the user click on a client and then on the "Visa Klient" (Show Client) button, or double click on the clientID.
    Then a windows with more detail information will open. Img2. The record is populated with the associated data exist for the sub form to the right. Except for the sub form which is listing all the "events" the client is associated with. As you can see both the records have a filed with the ClientID: "444444-4444". I'm trying to make the query only display the records with the same ClientID.
    Then if the user would like to see more detailed information about a certain event he or she would be able to click choose an event then press on the "Visa" (Preview) button, or double click on the ClientID.

    I'm not sure which form event this would be or how the could would look like.

    Then i have also built my main menu with a navigation control.

    The code.
    I haven't written any code for the event form so far.

    Main Menu. "Förhandsgranska/ Klient" (Preview/ Klient)
    Code:
    Option Compare DatabaseOption Explicit
    
    
    Dim SrchVal As String
    Dim SrchCrit As String
    Dim LastFld As String
    Dim fldName As String
    Dim FlitStr As String
    
    
    Private Function addCrLf(addValue As Integer) As String
        'Convenience routine to build a concatenated string of carriage returns / line feeds
        'given a specified count
        
        Dim intCount As Integer
        Dim strReturn As String
        
        strReturn = ""
            For intCount = 1 To addValue
                strReturn = strReturn & vbCrLf
            Next intCount
            
            addCrLf = strReturn
    End Function
    
    
    Private Sub cboFliterCity_GotFocus()
        Me.AllowEdits = True
        If Nz(FlitStr, "") = "" Then
            Me.cboFliterCity.RowSource = "SELECT DISTINCT tblClients.LastName FROM tblClients;"
        Else
            Me.cboFliterCity.RowSource = "SELECT DISTINCT tblClients.LastName FROM tblClients WHERE " & FlitStr & ";"
        End If
            Me.cboFliterCity.Dropdown
    End Sub
    
    
    Private Sub cboFliterCity_LostFocus()
        Me.AllowEdits = False
    End Sub
    
    
    Private Sub cboFliterOro_GotFocus()
        Me.AllowEdits = True
        If Nz(FlitStr, "") = "" Then
            Me.cboFliterOro.RowSource "SELECT DISTINCT tblErrand.Oro FROM tblErrand;"
        Else
            Me.cboFliterOro.RowSource "SELECT DISTINCT tblErrand.Oro FROM tblErrand WHERE " & FlitStr & ";"
        End If
            Me.cboFliterOro.Dropdown
    End Sub
    
    
    Private Sub cboFliterOro_LostFocus()
        Me.AllowEdits = False
    End Sub
    
    
    Private Sub cboFlitLastName_GotFocus()
        Me.AllowEdits = True
        If Nz(FlitStr, "") = "" Then
            Me.cboFlitLastName.RowSource = "SELECT DISTINCT tblClients.LastName FROM tblClients;"
        Else
            Me.cboFlitLastName.RowSource = "SELECT DISTINCT tblClients.LastName FROM tblClients WHERE " & FlitStr & ";"
        End If
            Me.cboFlitLastName.Dropdown
    End Sub
    
    
    Private Sub cboFlitLastName_LostFocus()
        Me.AllowEdits = False
    End Sub
    Private Sub txtClientID_DblClick(Cancel As Integer)
        Dim intID As String
        intID = Me!intID
    
    
          DoCmd.Close acForm, "frmClientsList"
          DoCmd.Close acForm, "frmClientsMenu"
          DoCmd.OpenForm "frmClientDetails", acNormal, "", "", acReadOnly, acDialog, OpenArgs:=intID
    End Sub
    
    
    Private Sub cmdVisa_Click()
        Dim intID As String
        intID = Me!intID
    
    
          DoCmd.Close acForm, "frmClientsList"
          DoCmd.Close acForm, "frmClientsMenu"
          DoCmd.OpenForm "frmClientDetails", acNormal, "", "", acReadOnly, acDialog, OpenArgs:=intID
    End Sub
    
    
    Private Sub lblAnmäldDatum_Click()
        If Me.OrderBy = "AnmäldDatum" Then
            Me.OrderBy = "AnmäldDatum DESC"
        Else
            Me.OrderBy = "AnmäldDatum"
        End If
    End Sub
    
    
    
    
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    
    
        On Error GoTo Err_Process
          Dim ctl As control
          Dim rs As Recordset
          
          Select Case KeyCode
                Case vbKeyEnd
                      KeyCode = 0
                      DoCmd.RunCommand acCmdRecordsGoToLast
                Case vbKeyHome
                    KeyCode = 0
                    DoCmd.RunCommand acCmdRecordsGoToFirst
                Case vbKeyUp
                    KeyCode = 0
                    DoCmd.RunCommand acCmdRecordsGoToPrevious
                Case vbKeyDown
                    KeyCode = 0
                    DoCmd.RunCommand acCmdRecordsGoToNext
                Case vbKeyRight, vbKeyLeft
                Case vbKeyPageUp, vbKeyPageDown
                    KeyCode = 0
                Case 9, 13    'tab or enter keys
                Case 8          'backspace key
                Case 48 To 57, 65 To 90
                   Set ctl = Screen.ActiveControl
                     fldName = ctl.Name
                     Select Case UCase(fldName)
                            Case "cboFlitLastName", "cboFliterCity", "cboFliterOro"
                                Exit Sub
                        End Select
                         If fldName <> LastFld Then
                            SrchVal = ""
                         End If
                   LastFld = fldName
                   SrchVal = SrchVal & Chr(KeyCode)
                   KeyCode = 0
                      If fldName = "Address" Then
                         SrchCrit = "[" & fldName & "] Like '*" & SrchVal & "*'"
                      Else
                         SrchCrit = "[" & fldName & "] Like '" & SrchVal & "*'"
                      End If
                   Set rs = Me.RecordsetClone
                      rs.FindFirst SrchCrit
                            If rs.NoMatch Then
                               MsgBox (" Record not found! ")
                            Else
                               Me.Bookmark = rs.Bookmark
                            End If
                   rs.Close
                   
                Case 107, 187
                   If SrchVal = "" Then
                      KeyCode = 0
                      Exit Sub
                   End If
                   Set ctl = Screen.ActiveControl
                         fldName = ctl.Name
                         KeyCode = 0
                   Set rs = Me.RecordsetClone
                         rs.Bookmark = Me.Bookmark
                         rs.FindNext SrchCrit
                               If rs.NoMatch Then
                                  MsgBox (" Record not found! ")
                               Else
                                  Me.Bookmark = rs.Bookmark
                               End If
                         rs.Close
                         
                Case 109, 189
                     If SrchVal = "" Then
                        KeyCode = 0
                        Exit Sub
                     End If
                     Set ctl = Screen.ActiveControl
                         fldName = ctl.Name
                         KeyCode = 0
                     Set rs = Me.RecordsetClone
                         rs.Bookmark = Me.Bookmark
                         rs.FindPrevious SrchCrit
                               If rs.NoMatch Then
                                  MsgBox (" Record not found! ")
                               Else
                                  Me.Bookmark = rs.Bookmark
                               End If
                     rs.Close
                Case 27
                   KeyCode = 0
                   SrchVal = ""
                Case Else
                   KeyCode = 0
    End Select
            
    Exit_Process:
        Exit Sub
    Err_Process:
            Select Case Err.Number
            Case 2046
            Case 2474
            Case Else
                MsgBox Err.Number & " " & Err.Description
            End Select
            Resume Exit_Process
    End Sub
    
    
    Private Sub Form_Open(Cancel As Integer)
        'Me.OrderBy = "ID"
        Me.OrderByOn = True
          Me.AllowAdditions = False
          Me.AllowEdits = False
          Me.AllowDeletions = False
        
        
    End Sub
    
    
    Private Sub cmdDeleteClient_Click()
        Dim strClient As String
        If MsgBox(" Du är på väg att RADERA en KLIENT. ALLA relaterade objekt kommer att försvinna. Är du SÄKER på att du vill radera denna klienten? OBS! detta går inte att ångra! ", vbYesNo) = vbYes Then
            strClient = "Klient: " & Me!intID & " # " & Me!txtClientID & addCrLf(2) & "Namn: " & addCrLf(1) & Me!FirstName & " - " & Me!LastName & addCrLf(2)
            Me.AllowDeletions = True
            DoCmd.RunCommand acCmdDeleteRecord
            Me.AllowDeletions = False
            MsgBox (" " & strClient & " Har raderats! ")
        End If
    End Sub
    
    
    Private Sub lblClient_ID_Click()
        If Me.OrderBy = "ClientID" Then
            Me.OrderBy = "ClientID DESC"
        Else
            Me.OrderBy = "ClientID"
        End If
        Me.AllowAdditions = False
        Me.AllowEdits = False
        Me.AllowDeletions = False
    End Sub
    
    
    Private Sub lblePost_Click()
        If Me.OrderBy = "ePost" Then
            Me.OrderBy = "ePost DESC"
        Else
            Me.OrderBy = "ePost"
        End If
    End Sub
    
    
    Private Sub lblFirstName_Click()
              If Me.OrderBy = "FirstName" Then
            Me.OrderBy = "FirstName DESC"
        Else
            Me.OrderBy = "FirstName"
        End If
    End Sub
    
    
    Private Sub lblHomeNumnber_Click()
        If Me.OrderBy = "HomeNumnber" Then
            Me.OrderBy = "HomeNumnber DESC"
        Else
            Me.OrderBy = "LastName"
        End If
    End Sub
    
    
    Private Sub lblID_Click()
        If Me.OrderBy = "intID" Then
            Me.OrderBy = "intID DESC"
        Else
            Me.OrderBy = "intID"
        End If
    End Sub
    
    
    Private Sub lblLastName_Click()
        If Me.OrderBy = "LastName" Then
            Me.OrderBy = "LastName DESC"
        Else
            Me.OrderBy = "LastName"
        End If
    End Sub
    
    
    Private Sub lblPhoneNumber_Click()
        If Me.OrderBy = "PhoneNumber" Then
            Me.OrderBy = "PhoneNumber DESC"
        Else
            Me.OrderBy = "PhoneNumber"
        End If
    End Sub
    
    
    Private Sub lblPoastAdress_Click()
        If Me.OrderBy = "PoastAdress" Then
            Me.OrderBy = "PoastAdress DESC"
        Else
            Me.OrderBy = "LastPoastAdressName"
        End If
    End Sub
    
    
    Private Sub lblPostOrt_Click()
        If Me.OrderBy = "PostOrt" Then
            Me.OrderBy = "PostOrt DESC"
        Else
            Me.OrderBy = "PostOrt"
        End If
    End Sub
    
    
    Private Sub lblRegistreradDatum_Click()
        If Me.OrderBy = "RegistreradDatum" Then
            Me.OrderBy = "RegistreradDatum DESC"
        Else
            Me.OrderBy = "RegistreradDatum"
        End If
    End Sub
    
    
    Private Sub lblRegistreradesAv_Click()
        If Me.OrderBy = "RegistreradesAv" Then
            Me.OrderBy = "RegistreradesAv DESC"
        Else
            Me.OrderBy = "RegistreradesAv"
        End If
    End Sub
    
    
    Private Sub lblAvRegistreradDatum_Click()
        If Me.OrderBy = "AvRegistreradDatum" Then
            Me.OrderBy = "AvRegistreradDatum DESC"
        Else
            Me.OrderBy = "AvRegistreradDatum"
        End If
    End Sub
    
    
    Sub BuildFlitStr()
        FiltStr = ""
            If Me!NameFlit <> "" Then
                FlitStr = "[LastName] = '" & Me!cboFlitLastName & "'"
            End If
            If Me!NameFlit <> "" Then
                If FiltStr = "" Then
                    FlitStr = "[CITY] = '" & Me!cboFliterCity & "'"
                Else
                    FlitStr = FiltStr & " [CITY] = '" & Me!cboFliterCity & "'"
            End If
            If Me!NameFilt <> "" Then
                FlitStr = "[Oro] = '" & Me!cboFliterOro & "'"
            End If
    End Sub


    The Preview Window
    Code:
    Option Compare DatabaseOption Explicit
    
    
    Private Sub cmdNewCase_Click()
        DoCmd.Close acForm, "frmClientDetails"
        DoCmd.OpenForm "frmErrand", acNormal, "", "", acFormAdd, acDialog
    End Sub
    
    
    Private Sub btnAddErrand_Click()
            Dim intID As String
            DoCmd.Close acForm, "frmMenu"
            DoCmd.Close acForm, "frmClientDetails"
            
            
            intID = Me!txtID
            DoCmd.OpenForm "frmErrandV2", acNormal, "", acFormAdd, OpenArgs:=intID
    End Sub
    
    
    Private Sub btnClose_Click()
        DoCmd.Close acForm, "frmClientDetails", acSaveNo
    End Sub
    
    
    Private Sub btnEN_Click()
                Me.lblH1.Caption = "Personal data:"
                    Me.lblClient_ID.Caption = "Client ID:"
                    Me.lblFirstName.Caption = "First name"
                    Me.lblLastName.Caption = "Last name"
                Me.lblH2.Caption = "Contact information"
                    Me.lblCity.Caption = "City"
                    Me.lblAdress.Caption = "Adress"
                    Me.lblEmail.Caption = "e-mail"
                    Me.lblHomeNumber.Caption = "Home Number"
                    Me.lblPhoneNumber.Caption = "Mobile Number"
                Me.lblH3.Caption = "Signature"
                    Me.lblRegisteredOf.Caption = "Registered by"
                    Me.lblRegisteredDate.Caption = "Registerd on"
            Me.btnAddErrand.Caption = "Add Case"
            Me.btnSave.Caption = "Save"
            Me.btnEdit.Caption = "Edit"
            Me.btnDelete.Caption = "Delete"
            Me.btnClose.Caption = "Close"
    End Sub
    
    
    Private Sub btnSE_Click()
                Me.lblH1.Caption = "Personuppgifter"
                    Me.lblClient_ID.Caption = "Personnummer"
                    Me.lblFirstName.Caption = "För Namn"
                    Me.lblLastName.Caption = "Efter Namn"
                Me.lblH2.Caption = "Kontaktuppgifter"
                    Me.lblCity.Caption = "Post ort"
                    Me.lblAdress.Caption = "Post Adress"
                    Me.lblEmail.Caption = "e-mail"
                    Me.lblHomeNumber.Caption = "Hem Nummer"
                    Me.lblPhoneNumber.Caption = "Mobil Nummer"
                Me.lblH3.Caption = "Signatur"
                    Me.lblRegisteredOf.Caption = "Registrerades den"
                    Me.lblRegisteredDate.Caption = "Registrerades av"
            Me.btnAddErrand.Caption = "Lägg till ärende"
            Me.btnSave.Caption = "Spara"
            Me.btnEdit.Caption = "Redigera"
            Me.btnDelete.Caption = "Radera"
            Me.btnClose.Caption = "Stäng"
    End Sub
    
    
    Private Sub Form_Open(Cancel As Integer)
    '    MsgBox (Me.OpenArgs)
          If Nz(Me.OpenArgs) = 0 Then
                'Me.RecordSource = "tblClients"
          Else
                Me.RecordSource = "SELECT tblClients.* FROM tblClients WHERE (((tblClients.ID)=" & Me.OpenArgs & "));"
          End If
          
    '      Dim ClintID As String
    '      ClintID = Me!txtClientID
    '
    '            DoCmd.OpenForm "frmClientSummerySub", acNormal, OpenArgs:=ClintID
          
          Me.txtID.Visible = False
          Me.btnEdit.Visible = True
          Me.btnSave.Visible = False
          Me.AllowEdits = False
          Me.AllowAdditions = False
          Me.AllowDeletions = False
    End Sub
    
    
    Private Sub btnSave_Click()
        If Me.btnSave.Visible = True Then
            Me.btnClose.SetFocus
            Me.AllowEdits = False
            Me.btnSave.Visible = False
            Me.btnEdit.Visible = True
        End If
    End Sub
    
    
    Private Sub btnEdit_Click()
        Me.AllowEdits = True
        If Me.btnEdit.Visible = True Then
            Me.txtClientID.SetFocus
            Me.btnEdit.Visible = False
            Me.btnSave.Visible = True
        End If
    End Sub

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Don't understand issue (language barrier interfering). Bind form to query. Open form filtered to desired record(s).
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    ThornofSouls's Avatar
    ThornofSouls is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Sweden, Gothenburg
    Posts
    42
    Is something unclear?
    Where do you encounter this language barrier?

    I have the from linked to a query which gets all the events within the database.


  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I downloaded and opened your database (from post #1).
    On the frmMenu, I selected "Förhandsgranska", nothing happened. I went to the Form's Design view, properties and looked at control related to "Förhandsgranska" , there was no event procedure???

    If there is a language barrier, it may simply be that readers are not sure what you need, and where/how to look for it. That's where I'm at, at the moment.

  10. #10
    ThornofSouls's Avatar
    ThornofSouls is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Sweden, Gothenburg
    Posts
    42
    Here is a newer version of the database, and i have translated most of it. I hope that will help with the language barrier, + there is a "SE" & "EN" button on some form in the top right corner which swap the language
    (a settings from with a language control would be nice)
    Click me for new version.

    That is because i have't written any code for the main menu it self. You can find the code through e the sub-menu buttons and sub forms. I believe These forms are sub-forms you can see through e the menu.

    This should be the structure of the forms if a leave the buttons out.


    • frmMenu

      • frmCover
      • frmClientAdd
      • frmCaseAdd_NEW
      • frmClientList
        • frmClientDetails + frmClientSummeryPre

      • frmClientSummery
        • frmCasePre


    If it looks like i have few equerry's it's because most of them are embedded or hard-coded with VBA and SQL.


    Otherwise is the structure of how i write the code easy, read?

    //Thorn

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Sorry, some syntax in posts was giving me impression English not your first language. The code is legible. I still can't download the file. I really don't understand what you need.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    ThornofSouls's Avatar
    ThornofSouls is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Sweden, Gothenburg
    Posts
    42
    Quote Originally Posted by June7 View Post
    Sorry, some syntax in posts was giving me impression English not your first language. The code is legible. I still can't download the file. I really don't understand what you need.
    It is okay, and English is my second language so some syntax's look kind of strange. I try to follow an English naming convention.

    What i need is what i believe is an "update query", and this query would run each time a certain form is opened.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Your OP states "so the query only would list the records with equal client id" - this indicates to me you want to filter records. Why would you need to run an UPDATE action - this would change data in records. So I still don't understand what you want.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    ThornofSouls's Avatar
    ThornofSouls is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Sweden, Gothenburg
    Posts
    42
    Yes i want to filter the form.



    1. I do not know how i send information to a form without open the form.
    2. I'm not sure which event i should use on the form which filters the ClientID
    3. Am i even on the right track?

    frmClientSummerySub is a sub-form of frmClientDetails, and am trying to make this subform filter the ClientID.

    This is the method i use to send the data to another form.

    This works just great when ever i'm opening another form. However this time i just want to send the information to another form without open the form.
    I do not know how i send information to another form without actually open the form or as a clone.

    Sending form
    frmClientList
    frmMenu / Navigation control / frmClientListfrmMenu, is mainly for navigation and design.
    frmClientList, pulls the information from tblClients.
    Code:
    Private Sub btnPreviewClient_Click()
        Dim intID As String
        intID = Me!intID
    
    
          'DoCmd.Close acForm, "frmClientsList"
          DoCmd.Close acForm, "frmClientsMenu"
          DoCmd.OpenForm "frmClientDetails", acNormal, "", "", acReadOnly, acDialog, OpenArgs:=intID
    End Sub
    
    
    Private Sub txtClientID_DblClick(Cancel As Integer)
        Dim intID As String
        intID = Me!intID
    
    
          DoCmd.Close acForm, "frmClientsList"
          DoCmd.Close acForm, "frmClientsMenu"
          DoCmd.OpenForm "frmClientDetails", acNormal, "", "", acReadOnly, acDialog, OpenArgs:=intID
    End Sub
    Receiving & Sending form
    frmClientDetails
    frmClientDetails
    pulls the information from tblClient with help of a query which receives the filter value with OpenArgs

    When the code below runs this happens:
    • Both the forms opens in a dialog window one at the time.
    • Or i receive an error at "ClientID = me!txtClientID" in frmClientDetails
      • Run-time error '13' .:
        Incompatible types
        The error occurs if i write "Dim ClientID As Integer".
        If i write "Dim ClientID As String" i don't receive a runtime error.
        If i write "Dim ClientID As Long" i receive an error.



    Code:
    Private Sub Form_Open(Cancel As Integer)
    '    MsgBox (Me.OpenArgs)
          If Nz(Me.OpenArgs) = 0 Then
                'Me.RecordSource = "tblClients"
          Else
                Me.RecordSource = "SELECT tblClients.* FROM tblClients WHERE (((tblClients.ID)=" & Me.OpenArgs & "));"
          End If
          
          'Filter frmClientSummerySub
          Dim ClientID As String
          ClientID = Me!txtClientID
                DoCmd.OpenForm "frmClientSummerySub", acNormal, "", "", acReadOnly, acDialog, OpenArgs:=ClientID
          MsgBox (Me!ClientID)
          
          Me.txtID.Visible = False
          Me.btnEdit.Visible = True
          Me.btnSave.Visible = False
          Me.AllowEdits = False
          Me.AllowAdditions = False
          Me.AllowDeletions = False
    End Sub
    This is the subform in this form, Image.

    When the form opens in a separate dialog window the following happens.


    • Image2. The form opens as it should according the current code but do not receive the data from "frmClientDetails"
    • Image3. "frmClientsDetails" opens correctly and the subform couldn't receive the requested "ClientID" from "frmClientDetails".


    Receiving form 2
    frmClientSummerySub
    frimClientSummerySub pulls information from
    I'm not sure which even i should use here when i'm sending the information to the form to filter the query.
    Code:
        If Nz(Me.OpenArgs) = 0 Then
                Me.RecordSource = "qryErrandSummeryID"
                MsgBox ("The filter could not recive the requested ID")
        Else
                Me.RecordSource = "SELECT tblErrand.ErrandID FROM tblErrand WHERE (((tblErrand.ErrandID)=" & Me.OpenArgs & "));"
        End If
        Debug.Print Me.OpenArgs

    I hope this an answer for you. If not please tell me what i'm missing so i can help you help me.
    //Thorn

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If all you want to do is filter records of a form - review http://www.allenbrowne.com/ser-62.html - this technique can be used to construct filter criteria to apply to open form or to apply to another form as it opens:

    DoCmd.OpenForm "formname", , , strWHERE
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-23-2015, 05:59 PM
  2. Replies: 4
    Last Post: 09-07-2014, 11:41 AM
  3. Replies: 3
    Last Post: 10-30-2012, 01:54 PM
  4. Replies: 2
    Last Post: 04-27-2012, 10:48 AM
  5. HELP! how to send data from table to text file
    By daveofgv in forum Import/Export Data
    Replies: 11
    Last Post: 02-14-2011, 01:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums