i need help here...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • squrel
    New Member
    • Jan 2008
    • 143

    i need help here...

    Hi everyone..
    I have a form called "showremind er". in this form i have 2 dtpicker 1 command button and 1 datagrid : DTPfromDt and DTPtoDt and cmdshowreminder , and MSHFlexGrid1...
    this form has to connect to one more form which is called as "reminders". in this form i have : txtid,txtcaseid ,txtreminder,cm breminderby,txt remindto,dtpent rydt,dtpclosedt ..

    when i select the fromdate and todate in my first form and press the commandbutton cmdshowreminder it has to connect to my second form and the gird has to show the data which its there between these selected date..

    i m trying to write a prcedure for tht bt its not working
    is it any way tht i can do it in the form and code itself???
    plz help me here
    thanks
  • squrel
    New Member
    • Jan 2008
    • 143

    #2
    i m trying this code bt my grid is coming empty
    how to connect the fromdt and todt from this form to the other form wit entrydt and closedt?



    Private Sub cmdshowreminder _Click()
    Dim sQuery As String
    If FieldName = "DTPfromdt" And FieldName = "DTPtodt" Then
    sQuery = "select id, caseid,convert( VarChar(20), reminders.remin ddt, 6), reminder, reminderby, reminderto From reminders"

    Adodc1.Connecti onString = pStrConnectionS tring
    Adodc1.RecordSo urce = sQuery
    Adodc1.Refresh
    Set frmReminders.MS HFlexGrid1.Data Source = Adodc1
    Set frmReminders.MS HFlexGrid1.Reco rdset = Adodc1.Recordse t
    Adodc1.Refresh
    frmReminders.MS HFlexGrid1.ColW idth(1) = 500
    frmReminders.MS HFlexGrid1.ColW idth(2) = 500
    frmReminders.MS HFlexGrid1.ColW idth(3) = 1000
    frmReminders.MS HFlexGrid1.ColW idth(4) = 2000
    frmReminders.MS HFlexGrid1.ColW idth(5) = 2000
    frmReminders.MS HFlexGrid1.ColW idth(5) = 2000
    frmReminders.MS HFlexGrid1.Refr esh
    end if
    End Sub

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      Post the Code here, If there is any problem with the code, we can let you know.. Also, What format is the date Displayed in the FlexGrid..?

      Regards
      Veena

      Comment

      • squrel
        New Member
        • Jan 2008
        • 143

        #4
        [img]file:///C:/DOCUME%7E1/AZITA%7E1.MOS/LOCALS%7E1/Temp/moz-screenshot.jpg[/img]this is my code and my date format is mm/dd/yyyy
        my grid is empty when i click on cmdshowreminder
        how can i connected these 2 tables together and get the grid according to selected date
        thank u



        Private Sub cmdshowreminder _Click()
        Dim sQuery As String
        If FieldName = "DTPfromdt" And FieldName = "DTPtodt" Then
        sQuery = "select id, caseid,convert( VarChar(20), reminders.remin ddt, 6), reminder, reminderby, reminderto From reminders"

        Adodc1.Connecti onString = pStrConnectionS tring
        Adodc1.RecordSo urce = sQuery
        Adodc1.Refresh
        Set frmReminders.MS HFlexGrid1.Data Source = Adodc1
        Set frmReminders.MS HFlexGrid1.Reco rdset = Adodc1.Recordse t
        Adodc1.Refresh
        frmReminders.MS HFlexGrid1.ColW idth(1) = 500
        frmReminders.MS HFlexGrid1.ColW idth(2) = 500
        frmReminders.MS HFlexGrid1.ColW idth(3) = 1000
        frmReminders.MS HFlexGrid1.ColW idth(4) = 2000
        frmReminders.MS HFlexGrid1.ColW idth(5) = 2000
        frmReminders.MS HFlexGrid1.ColW idth(5) = 2000
        frmReminders.MS HFlexGrid1.Refr esh

        end if
        end sub

        Comment

        • squrel
          New Member
          • Jan 2008
          • 143

          #5
          wld u plz check my code and help me out in this matter..
          thank u

          Comment

          • QVeen72
            Recognized Expert Top Contributor
            • Oct 2006
            • 1445

            #6
            Hi,

            Change Your Query Like this :

            [code=vb]
            sQuery = "select id, caseid,convert( VarChar(20), reminders.remin ddt, 6), " _
            & " reminder, reminderby, reminderto From reminders Where reminddt " _
            & " Between #" & Format(Form1.Dt pFrom.Value,"dd-mm-yyyy") & "# " _
            & " And #" & Format(Form1.Dt pTo.Value,"dd-mm-yyyy") & "# "
            [/code]

            Change datepicker control names accordingly...

            Regards
            Veena
            Last edited by QVeen72; Jan 12 '09, 09:33 AM. Reason: added code tags

            Comment

            • squrel
              New Member
              • Jan 2008
              • 143

              #7
              i have changed the code the way u told me bt sitll my gird is empty.. there is no error coming bt nothing showing in the gird



              Private Sub cmdshowreminder _Click()
              Dim sQuery As String
              If FieldName = "DTPfromdt" And FieldName = "DTPtodt" Then
              sQuery = "select id, caseid,convert( VarChar(20), reminders.remin ddt, 6), " _
              & " reminder, reminderby, reminderto From reminders Where reminddt " _
              & " Between #" & Format(frmShowR eminder.DTPfrom Dt.Value, "dd-mm-yyyy") & "# " _
              & " And #" & Format(frmShowR eminder.DTPtoDt .Value, "dd-mm-yyyy") & "# "
              Adodc1.Connecti onString = pStrConnectionS tring
              Adodc1.RecordSo urce = sQuery
              Adodc1.Refresh
              Set frmReminders.MS HFlexGrid1.Data Source = Adodc1
              Set frmReminders.MS HFlexGrid1.Reco rdset = Adodc1.Recordse t
              Adodc1.Refresh
              frmReminders.MS HFlexGrid1.ColW idth(1) = 500
              frmReminders.MS HFlexGrid1.ColW idth(2) = 500
              frmReminders.MS HFlexGrid1.ColW idth(3) = 1000
              frmReminders.MS HFlexGrid1.ColW idth(4) = 2000
              frmReminders.MS HFlexGrid1.ColW idth(5) = 2000
              frmReminders.MS HFlexGrid1.ColW idth(5) = 2000
              frmReminders.MS HFlexGrid1.Refr esh
              End If
              End Sub

              Comment

              • squrel
                New Member
                • Jan 2008
                • 143

                #8
                i m still not getting anything in my grid.... is my query rit?
                plz help me in this matter

                Comment

                • QVeen72
                  Recognized Expert Top Contributor
                  • Oct 2006
                  • 1445

                  #9
                  Hi,

                  I Guess, You are using SQL Server, My Query was for access..
                  Slight change in syntax:

                  " MyFldDate Between Convert(Datetim e,'" _
                  & Format(dtpF.Val ue, "mmm dd yyyy") & "') And " _
                  & " Convert(Datetim e,'" & Format(dtpT.Val ue, "mmm dd yyyy") & "')"


                  Regards
                  Veena

                  Comment

                  • squrel
                    New Member
                    • Jan 2008
                    • 143

                    #10
                    Hi Veena,
                    i m sorry to trouble... yes i m using sqlserver 2000 and VB6
                    i paste the query bt the problem when i go to debug my field name is showing empty and directly is coming out of if loop and goes to end if and end sub it does not go through the squery and the grid thts why is not showing anything in my grid.. bt does not understand why?? i m pasting the code here wld u plz check it out.. in the line which i made it bold shows the field name is empty and directly goes to the end if and and does not read anything...
                    anything wrong in tht line??
                    thank u



                    Private Sub cmdshowreminder _Click()
                    Dim sQuery As String
                    Dim FieldName As String

                    If (FieldName = "DTPfromdt" And FieldName = "DTPtodt") Then


                    sQuery = "select id, caseid,convert( VarChar(20), reminders.remin ddt, 6)," _
                    & " reminder, reminderby, reminderto From reminders,showr eminder Where reminddt Between Convert(Datetim e,'" _
                    & " Between " & Format(frmShowR eminder.DTPfrom Dt.Value, "dd-mm-yyyy") & " #" _
                    & " and " & Format(frmShowR eminder.DTPtoDt .Value, "dd-mm-yyyy") & ""

                    Adodc1.Connecti onString = pStrConnectionS tring
                    Adodc1.RecordSo urce = sQuery
                    Adodc1.Refresh
                    Set frmReminders.MS HFlexGrid1.Data Source = Adodc1
                    Set frmReminders.MS HFlexGrid1.Reco rdset = Adodc1.Recordse t
                    Adodc1.Refresh
                    frmReminders.MS HFlexGrid1.ColW idth(1) = 500
                    frmReminders.MS HFlexGrid1.ColW idth(2) = 500
                    frmReminders.MS HFlexGrid1.ColW idth(3) = 1000
                    frmReminders.MS HFlexGrid1.ColW idth(4) = 2000
                    frmReminders.MS HFlexGrid1.ColW idth(5) = 2000
                    frmReminders.MS HFlexGrid1.ColW idth(5) = 2000
                    frmReminders.MS HFlexGrid1.Refr esh
                    End If
                    End Sub

                    Comment

                    • QVeen72
                      Recognized Expert Top Contributor
                      • Oct 2006
                      • 1445

                      #11
                      Hi,

                      Why are you checking this line..?
                      If (FieldName = "DTPfromdt" And FieldName = "DTPtodt") Then

                      Remove that IF condition..
                      Since you are declaring the FieldName there itself, it would be blank, and hence cannot enter IF condition


                      Regards
                      Veena

                      Comment

                      • squrel
                        New Member
                        • Jan 2008
                        • 143

                        #12
                        ok.. i have removed the if loop bt its giving me error as :

                        "Incorrect syntax near the keyword 'between' . and after tht it gives me error as : "method 'Refresh' of object 'IAdodc' failed"

                        i have tried 2 types of query... bt still is giving me error ..

                        1)

                        sQuery = "select id, caseid,convert( VarChar(20), reminders.remin ddt, 6)," _
                        & " reminder, reminderby, reminderto From reminders,showr eminder Where reminddt & " _
                        & " Between Convert(varchar (20),frmshowrem inder.DTPfromDt ,6) And " _
                        & " Convert(varchar (20),frmshowrem inder.DTptodt,6 ) & "


                        2)

                        sQuery = "select id, caseid,convert( VarChar(20), reminders.remin ddt, 6)," _
                        & " reminder, reminderby, reminderto From reminders,showr eminder Where reminddt & " _
                        & " Between Convert(Datetim e,'" & Format(frmShowR eminder.DTPfrom Dt.Value, "dd-mm-yyyy") & "') And " _
                        & " Convert(Datetim e,'" & Format(frmShowR eminder.DTPtoDt .Value, "dd-mm-yyyy") & "')"


                        i dont knw really wht is the problem.... the query is working in query analyzer bt giving me error in VB... wht else i have to do???? :(((((((((((

                        Comment

                        • squrel
                          New Member
                          • Jan 2008
                          • 143

                          #13
                          Thank u very much
                          finally i got it :)))

                          Comment

                          Working...