Don't have any idea what is wrong

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lgoddgreat
    New Member
    • Jun 2015
    • 13

    Don't have any idea what is wrong

    Hello can anyone tell me what is wrong with my query/codes

    I have 3 search types: keyword Search, Position Search, Advance Search. for example i used Advance search, I type in a few Criteria and after I'm done ill press search and a Report will pop up and show all the query results, then I have the choice on wether I will open 1 up or not by clicking the Control Number.

    [IMGnothumb]http://i.imgur.com/6t7aBg1.png[/IMGnothumb]

    after clicking the control number a "msgbox"(FO RM) will pop up and ask you if you would want to save the file.


    [IMGnothumb]http://i.imgur.com/3kHgKmA.png[/IMGnothumb]
    if you click Save, then a new form will pop up showing all the Information about the Control number.

    [IMGnothumb]http://i.imgur.com/xuCAX9S.png[/IMGnothumb]

    The query:
    Code:
    SELECT Master.Name, Master.[Control Number], Master.Age, Master.Contact1, Master.Contact2, Master.Contact3, Master.Email, Master.Address, Master.Position1, Master.Gender, Master.[Work Experience], Master.Education, Master.Attachment, Master.Experience, Master.[Position Level], Master.Attachment, Master.Specialization, Master.Status, Master.[Remark/s], Master.EducationalBackground, Master.Education, Master.Experience
    FROM Master
    WHERE (((Master.[Control Number])=[Reports]![Keyword_REPORT_SMDG]![Control Number]));
    This part here is all working fine, The advance search is flawless (I think), but What I'm confused about is why do my other 2 search type is not working the way i want to, the searching is ok on the other 2 but when I click the Control number that I want to view, it keeps on viewing the 1st result on my query, I've tried recreating the search types and created new query but It still the same, here is my Query for the other 2:

    Keyword:
    Code:
    SELECT Master.Name, Master.[Control Number], Master.Age, Master.Contact1, Master.Contact2, Master.Contact3, Master.Email, Master.Address, Master.Position1, Master.Gender, Master.[Work Experience], Master.Education, Master.Attachment, Master.Experience, Master.[Position Level], Master.Attachment, Master.Specialization, Master.Status, Master.[Remark/s], Master.EducationalBackground, Master.Education, Master.Experience
    FROM Master
    WHERE (((Master.[Control Number])=[Reports]![Keyword_REPORT_SMDG]![Control Number]));
    Position:
    Code:
    SELECT Master.Name, Master.[Control Number], Master.Age, Master.Contact1, Master.Contact2, Master.Contact3, Master.Email, Master.Address, Master.Position1, Master.Gender, Master.[Work Experience], Master.Education, Master.Attachment, Master.Experience, Master.[Position Level], Master.Attachment, Master.Specialization, Master.Status, Master.[Remark/s], Master.EducationalBackground, Master.Education, Master.Experience
    FROM Master
    WHERE (((Master.[Control Number])=[Reports]![Simple_Query REPORT]![controlTB]));
    Notice that the 3 queries are Identical, and that is what I'm confused about its basically A copy paste of one another but I dont get it why they dont work, except for the Advance search. if you need more Information, I can give it to you but right now I dont know what to show you people except the query and the images.

    cheers
    Last edited by TheSmileyCoder; Aug 25 '15, 08:07 AM. Reason: Fixed image links
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1291

    #2
    Show us the code that launches the query or form that is showing the wrong information. When the click is made, what vba code are you running to get to this query?

    Jim

    Comment

    • lgoddgreat
      New Member
      • Jun 2015
      • 13

      #3
      This is the VBA codes that I used when launching the Form, this is inside the saveFORM or the form which prompts you to either save or cancel.

      Code:
      Option Compare Database
      
      Private Sub cancelBTN_Click()
      
      DoCmd.Close
      
      End Sub
      
      Private Sub Form_Timer()
      
      Me.timelbl.Caption = Now()
      
      End Sub
      
      Private Sub saveBTN_Click()
      
      Dim db As Database
      Dim rec As Recordset
      
      Set db = CurrentDb
      Set rec = db.OpenRecordset("SELECT * FROM activityTBL")
      
      rec.AddNew
      rec("date/time") = Now()
      rec("Control_Number") = Reports![Simple_Query REPORT]![controlTB]
      rec("Requesters_name") = Me.requestedBY.Value
      rec.Update
      
      DoCmd.Close
      DoCmd.OpenForm "Position_cvFORM"
      
      Set db = Nothing
      Set rec = Nothing
      
      
      End Sub
      The query inside the "Position_cvFOR M" is:

      Code:
      SELECT Master.Name, Master.[Control Number], Master.Age, Master.Contact1, Master.Contact2, Master.Contact3, Master.Email, Master.Address, Master.Position1, Master.Gender, Master.[Work Experience], Master.Education, Master.Attachment, Master.Experience, Master.[Position Level], Master.Attachment, Master.Specialization, Master.Status, Master.[Remark/s], Master.EducationalBackground, Master.Education, Master.Experience
      FROM Master
      WHERE (((Master.[Control Number]) Like [Reports]![Simple_Query REPORT]![controlTB]));

      Comment

      • lgoddgreat
        New Member
        • Jun 2015
        • 13

        #4
        I'll add this following VBA codes here:

        VBA code inside my Report.

        Code:
        Option Compare Database
        
        Private Sub Attachment_Click()
        
        Dim db As Database
        Dim rec As Recordset
        
        Set db = CurrentDb
        Set rec = db.OpenRecordset("activityTBL")
        
        rec.AddNew
        rec("date/time") = Now()
        rec("Control_Number") = Me.Control_Number
        rec.Update
        
        Set db = Nothing
        Set rec = Nothing
        
        DoCmd.OpenForm "keywordcvFORM"
        
        End Sub
        
        Private Sub advbtn_Click()
        
        Dim response1 As Integer
        
        reponse1 = MsgBox("Are you sure you want to get out of here?", vbYesNo)
        
        If response1 = vbYes Then
        
        DoCmd.OpenForm "AdvanceSearchFORM_SMDG"
        
        Else
        
        End If
        
        End Sub
        
        Private Sub controlTB_Click()
        
        DoCmd.OpenForm "POSITIONsaveform_SMDG"
        
        End Sub
        
        Private Sub homeBTN_Click()
        
        Dim userResponse As String
        
        userResponse = MsgBox("Are you sure you want to go back home?", vbYesNo)
        
        If userResponse = vbYes Then
        
        DoCmd.Close
        DoCmd.OpenForm "adminFORM"
        
        Else
        
        End If
        End Sub
        
        
        
        End Sub
        
        Private Sub Report_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Screen.MousePointer = 1
        End Sub
        
        Private Sub returnBTN_Click()
        
            DoCmd.Close
        
        End Sub
        and also the query in my position search:
        Code:
        SELECT Master.[Control Number], Master.Age, Master.[Position Level], Master.Position1, Master.Experience, Master.Gender, Master.[Work Experience], Master.Education, Master.Attachment, Master.Attachment.FileData, Master.Attachment.FileName, Master.Attachment.FileType, Master.[Remark/s], Master.Status
        FROM Master
        WHERE (((Master.Position1) Like "*" & [Forms]![PositionSearchFORM]![positionTB] & "*"));
        Im kinda new to VBA and I have limited amount of knowledge about it. before all of this was working fine, and suddenly the two search functions went like this, I dont have any idea why.

        Comment

        • jimatqsi
          Moderator Top Contributor
          • Oct 2006
          • 1291

          #5
          Are you aware that you can pass a where string to the OpenForm command? That may be a better approach. So your openform would be something like this:
          Code:
          dim whr as string
          whr = " (((Master.[Control Number])=" & [Reports]![Simple_Query REPORT]![controlTB]))
          DoCmd.OpenForm "Position_cvFORM", acNormal, ,whr, , acNormal
          Study the parameters available for the OpenForm method of DoCmd.

          Jim

          Comment

          • lgoddgreat
            New Member
            • Jun 2015
            • 13

            #6
            I dont have any idea or whatsoever, I only have a small amount of knowledge regarding this. Thanks for the reply, Ill try that approach, if it works I'll tell you.

            Comment

            • lgoddgreat
              New Member
              • Jun 2015
              • 13

              #7
              It is working now, your solution or idea wasnt able to fix my problem but it did lead me to the solution that I was looking for, I'm very grateful for helping me Jim. Thanks, have a great day!

              Comment

              • jimatqsi
                Moderator Top Contributor
                • Oct 2006
                • 1291

                #8
                I'm pleased you got it working, especially pleased you could devise your own solution. But please show the code or explain the solution so others can learn from your efforts.

                Good job. It can be a very difficult thing to get started with Access. Persistence pays.

                Jim

                Comment

                Working...