INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Figure out the bigger dataset

Figure out the bigger dataset

(OP)
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 --> VB.NET

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

RE: Figure out the bigger dataset

"So the above code gets me what I need" - not really...

CODE

Dim DataConnect As New Data_Connection_Final

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

Dim TBH As String = "" 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.

RE: Figure out the bigger dataset

(OP)
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 

RE: Figure out the bigger dataset

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.

RE: Figure out the bigger dataset

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close