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

Figure out the bigger dataset

Status
Not open for further replies.

Igawa29

MIS
Jan 28, 2010
99
0
0
US
So what I am trying to do is to figure out between two tables which one has the bigger Record ID. Once I find that out I want to output this number with a +1 to a text box.
Code:
        Dim DataConnect As New Data_Connection_Final

        Dim Staff As String = ""
        Dim DataPullStaff As New DataSet
        Staff = "Select MAX([Record ID]) from Staff_Position"
        DataPullStaff = DataConnect.GetDataSet(Staff)

        Dim TBH As String = ""
        Dim DataPullTBH As New DataSet
        TBH = "Select MAX([Record ID]) from TBH_Position"
        DataPullTBH = DataConnect.GetDataSet(TBH)

So the above code gets me what I need, however I am not sure how to put an if statement that if one is greater than the other to output the number +1 to me.record_id.text
 
So the above code gets me what I need" - not really...

Code:
Dim DataConnect As New Data_Connection_Final

Dim Staff As [s]String = ""[/s] Long
Dim DataPullStaff As New DataSet
Staff = "Select MAX([Record ID]) from Staff_Position"
DataPullStaff = DataConnect.GetDataSet(Staff)

Dim TBH As [s]String = ""[/s] Long
Dim DataPullTBH As New DataSet
TBH = "Select MAX([Record ID]) from TBH_Position"
DataPullTBH = DataConnect.GetDataSet(TBH) 

If Staff > TBH Then
    Staff += 1
ElseIf Staff < TBH Then
    TBH += 1
Else
    MsgBox "Staff and TBH are equal"
End If

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Thanks Andy, but I am having some issues trying to output the result to a textbox on my form.

Trying this is giving me a few errors, do you have any suggestions?
Code:
        If Staff > TBH Then
            Me.RecordID_TEXT = DataPullStaff.Tables(0).Rows(1).Item(1)
        ElseIf Staff < TBH Then
            Me.RecordID_TEXT = DataPullTBH.Tables(0).Rows(1).Item(1)
        Else
            MsgBox("Staff and TBH are equal")
        End If
 
How about:

Code:
If Staff > TBH Then
    Me.RecordID_TEXT.Text = Staff + 1
ElseIf Staff < TBH Then
    Me.RecordID_TEXT.Text = TBH + 1
Else
    MsgBox("Staff and TBH are equal")
End If

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Thanks Andy,
I have finally figured out how to get it working


Code:
Dim Staff As String = ""
        Dim DataPullStaff As New DataSet
        Staff = "Select MAX([Record ID]) from Staff_Position"
        DataPullStaff = DataConnect.GetDataSet(Staff)

        Dim TBH As String = ""
        Dim DataPullTBH As New DataSet
        TBH = "Select MAX([Record ID]) from TBH"
        DataPullTBH = DataConnect.GetDataSet(TBH)

        Dim IntStaff As Integer = DataPullStaff.Tables(0).Rows(0).Item(0)
        Dim IntTBH As Integer = DataPullTBH.Tables(0).Rows(0).Item(0)


        If IntStaff > IntTBH Then
            me.RecordID_TEXT.Text = CStr(IntStaff + 1)
        ElseIf IntStaff < IntTBH Then
            me.RecordID_TEXT.Text = CStr(IntTBH + 1)
        Else
            MsgBox("Staff and TBH are equal")
        End If

Its loading right into my table now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top