kRod 49 Junior Poster

This is the structure of a CSV File yours loads into a datagrid but the info is all lumped together

EXTENSION,DESCRIPTION,EXECUTABLE_PATH
.001,None,C:\Program Files\7-Zip\7z.exe
.323,H.323 Internet Telephony,rundll32.exe
.386,Virtual device driver,NO DEFAULT PROGRAM SET
.3g2,3GPP2 Movie,C:\Program Files\QuickTime\QuickTimePlayer.exe
.3gp,3GPP Movie,C:\Program Files\QuickTime\QuickTimePlayer.exe
.3gp2,3GPP2 Movie,C:\Program Files\QuickTime\QuickTimePlayer.exe
.3gpp,3GPP Movie,C:\Program Files\QuickTime\QuickTimePlayer.exe
.669,Composer 669 Module,NO DEFAULT PROGRAM SET
.7z,None,C:\Program Files\7-Zip\7z.exe
.aa,None,NO DEFAULT PROGRAM SET
.aac,None,C:\Program Files\QuickTime\QuickTimePlayer.exe
.aax,None,NO DEFAULT PROGRAM SET

Anyway try the following code after you load the datatable

 For i As Integer = 0 To 9
     ds.Tables(0).Rows(i).Delete()
 Next

  ds.Tables(0).AcceptChanges()

It should remove all the rows above the START row.

kRod 49 Junior Poster

Please post some of your CSV file. We do n ot know what your column names are or what your data looks like.

kRod 49 Junior Poster

As for your wanting rows 98 - 156 use the following.
cnt is an integer variable: cnt = objDataset.Tables(0).Rows.Count - 1

 For i As Integer = cnt To 0 Step -1
            If i < 98 Or i > 156 Then
                objDataset1.Tables(0).Rows(i).Delete()

            End If
        Next
        ds.Tables(0).AcceptChanges()

I would like to see a sample of your csv file the first 3 rows should be enough.

kRod 49 Junior Poster

Where line of code caused "No value given for one or more required parameters. i got this error sir" error?

kRod 49 Junior Poster

Does your DataAdapter have an Update Command Query Set? Also remove
BindingSource1.ResetBindings(False)

Does your ACCESS table have a Primary Key?

kRod 49 Junior Poster

If your CSV File has headers you can Just get the columns you want by the SELECT Query.

 Dim objCmdSelect As New OleDbCommand("SELECT Col1,Col2,col3... FROM " & fi.Name, objConn)
kRod 49 Junior Poster

I haven't had a chance to test this but I'm pretty sure you can ->Instead of deleting your record from the datatable. Me.TransmissoesDataSet.Tables("utilizador_Avancado").Rows(itemFound).Delete()

Remove the item from the BindingSource and call ResetBindings(False) Method.

 bs.RemoveAt(itemFound)
 bs.ResetBindings(False)

Then Accept changes method on the table. You should be able to use the Adapter Update then.

kRod 49 Junior Poster

What exactly are you trying to do? You have an array of Button then you give a variable btnName a type Button without using it. Then you take your button in the array and try to create a new button without the array index. Not sure what event handler you are using either I suppose it's the click events for both buttons you have in the array.

Anyway I believe your problem is the array is not being loaded when the form is opened. i ran your code and added the buttons to the array in the load event. Not sure why your looping thru the array and setting the value of toothName it will always be your second button name

    Dim btns(1) As Button
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Try
            btns(0) = Me.Button1
            btns(1) = Me.Button2
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try


    End Sub

    Private Sub Button_Click(sender As Object, e As EventArgs) Handles Button1.Click, Button2.Click
        'Dim btnName As Button = DirectCast(sender, Button)
        Dim i As Integer
        'btns(i) = New Button
        Dim toothName As String = ""

        Try
            For i = 0 To btns.Length - 1
                toothName = " " & btns(i).Text & " - Upper " '<- in here it says Object reference not set to an instance of an object
            Next
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try


    End Sub

That will stop your Object Reference Not Set Error and maybe you can go on from there

kRod 49 Junior Poster

The following code shows how to put a table and some other minor things into a word doc. It's part of a database schema app. displaying the table name column names and their datatype ordinal position and if nullable. So the dbname and the table name are not important just strings. the datatable has to have data with column names. You will also need a reference to Microsoft.Office.Interop.Word

Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Word

Public Class WordDoc

    ''' <summary>
    ''' dTbl - The table you wish to display
    ''' tblName - Name of the Table 
    ''' dbName - the database File Path and Name
    ''' </summary>
    ''' <param name="dTbl"></param>
    ''' <param name="tblName"></param>
    ''' <param name="dbName"></param>
    ''' <remarks></remarks>
    Public Sub New(ByVal dTbl As DataTable, ByVal tblName As String, ByVal dbName As String)

        Dim oApp As Word.Application
        Dim oDoc As Word.Document
        Dim oPara1 As Word.Paragraph
        Try
            'Start a new document in Word                    
            oApp = CType(CreateObject("Word.Application"), Word.Application)

            oDoc = oApp.Documents.Add()


            Dim rws As Integer = dTbl.Rows.Count
            Dim cols As Integer = dTbl.Columns.Count

            ' Clear out any existing information.
            oDoc.Range.Delete()

            oPara1 = oDoc.Content.Paragraphs.Add
            oPara1.Range.MoveStart()
            oPara1.Range.Text = tblName & " TABLE"
            oPara1.Range.Font.Size = 10
            oPara1.Range.Font.Bold = CInt(True)
            oPara1.Format.SpaceAfter = 4
            oPara1.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft

            oPara1.Range.InsertParagraphAfter()

            Dim tlb As Word.Table
            tlb = oDoc.Tables.Add(oDoc.Bookmarks.Item("\endofdoc").Range, CInt(rws + 1), CInt(cols))

            oApp.Visible = True
            tlb.Style = "Table Grid 8" '"wdTableFormatGrid8"  '"Table Grid 7" "Table Columns 5"

                'Data Rows 
            For j As Integer = 0 To CInt(rws) 'no -1 here as the headers need to be added

                If j = 0 Then
                    For …
kRod 49 Junior Poster

If your problem is solved you should mark it as such.

kRod 49 Junior Poster

Quick and dirty demo

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim filePathAndName As String = SelectFile()

        If filePathAndName IsNot Nothing Then
            Dim dir As String = GetFolder()
            If dir IsNot Nothing Then
                My.Computer.FileSystem.CopyFile(filePathAndName, dir & "\" & _
                                                System.IO.Path.GetFileName(filePathAndName), True)
            End If
        End If
    End Sub

    Private Function GetFolder() As String

        Dim fldr As String = Nothing

        With fbd1
            .Description = "SELECT DIRECTORY FOR EXCEL FILE"
            .ShowNewFolderButton = True
            Dim dlgResult As DialogResult = .ShowDialog()
            If dlgResult = Windows.Forms.DialogResult.OK Then
                fldr = .SelectedPath
            Else
                MsgBox("EXCEL FILE WASN'T SAVED")
                fldr = Nothing
                Return fldr
                Exit Function
            End If

        End With


        Return fldr

    End Function


    Private Function SelectFile() As String
        Dim file As String = Nothing

        With ofd1
            .InitialDirectory = "c:\"
            .Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
            .Multiselect = False
            .RestoreDirectory = True
            If .ShowDialog = DialogResult.OK Then
                file = .FileName
            End If
        End With

        Return file

    End Function



End Class
kRod 49 Junior Poster

You didn't provide the name for the file in the destination

My.Computer.FileSystem.CopyFile("C:\Users\coder\Desktop\EXCEL PROJECT\excel\1_2012.xlsx", My.Computer.FileSystem.SpecialDirectories.Desktop & "\TestCopy.xlsx", True)

Click Here

kRod 49 Junior Poster

Why not look for the LastIndexOf("0")

Click Here

kRod 49 Junior Poster

I see in 3 subs you are creating the same named dataset--> DtSet. The DataSet needs to be Global enough for the consumers of it within the project. This is probably why you are getting the * object reference not set to an instance of an object* error.

kRod 49 Junior Poster

If your question has been answered satisfactorily please mark the thread as solved.

kRod 49 Junior Poster

Try the following

Dim id as Integer = Command.ExecuteScalar()
kRod 49 Junior Poster

In your Sub newGame() You are Dim(ing) a variable named randomNumber instead of just reassigning your global variable new value. Since it's scope is local to only the Sub newGame it will have no effect on the global variable randomNumber and it will be whatever you assigned it in the beginning.

kRod 49 Junior Poster

TextBox1.Text = Cstr(Value from the Query)

kRod 49 Junior Poster

What value are you trying to put into the textbox? What column and row in the underlying dataSource is it in ? Do you need to search the dataSource for the value or does your query select a single value --- 'Command.ExecuteScalar' As you can see there is a lot of info we would need to answer your question. Showing the code that retrieves the data would help alot....

kRod 49 Junior Poster
kRod 49 Junior Poster

I'm working on a small database app to organize my song files and threw together this little sub to demonstrate a Null value in one of the columns of a record. It's OldeDB but should easily be adapted to SQL.

I purposely left the Album name out on one of the records and it worked as expected! Below are the Column Names.

ID  ALBUM   ARTIST  TITLE   RELEASED    LOCATION    BIT_RATE    [SIZE]  DURATION    GENRE




    Private Sub Search_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim startUp As String = Environment.CurrentDirectory
        Dim conStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & startUp & "\MusicList.accdb;Persist Security Info=False;"

        Dim sql As String = "Select * From SONGS"
        Dim conn As New OleDb.OleDbConnection(conStr)

        Dim cmd As New OleDb.OleDbCommand()
        With cmd
            .CommandText = sql
            .CommandType = CommandType.Text
            .Connection = conn
        End With

        Dim rdr As OleDb.OleDbDataReader

        conn.Open()
        rdr = cmd.ExecuteReader
        While rdr.Read
            'Check if the Second Column is null
            'if so report the song name 
            'first column is AutoNumber "ID" Second Column is the "Album"
            If rdr.IsDBNull(1) Then 'Checking 2nd Column for null
                MsgBox(rdr.GetValue(3).ToString)
            End If
        End While

       conn.Close
    End Sub

Hope this points you in the right direction...

kRod 49 Junior Poster

When I use a DataAdapter and the CommandBuilder with a BindingSource I call the Update on the DataAdapter as follows.

 da.Update(ds, "TableName")
kRod 49 Junior Poster

How did you load the DataGridView? Where did that data come from?

kRod 49 Junior Poster
 Private Sub CreateNewAccessTable()
        Dim dataBasePath As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\access.mdb"
        Dim tableName As String = "nameOfYourNewTable"

        'Create a new table using OLEDB Provider  
        Dim con As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" & dataBasePath)
        con.Open()

        'Get data Table schema  
        Dim dbSchema As DataTable = con.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, tableName, "TABLE"})
        con.Close()
        ' If the table exists, the count = 1 
        If dbSchema.Rows.Count > 0 Then
            'if the table exists
            'inform user and exit Sub

            MsgBox("Table Exists")
        Else

            'Create the new table 
            Dim cmd As New OleDb.OleDbCommand("CREATE TABLE [" + tableName + "] ([Field1] TEXT(10), [Field2] TEXT(10))", con)
            con.Open()
            cmd.ExecuteNonQuery()
            MessageBox.Show("Table Created Successfully")
            con.Close()
        End If

    End Sub
kRod 49 Junior Poster

Why do you need to create an entire new database? Why not just create a new table to hold the new year's data? If you are set on creating a new DB then check out this link Click Here

kRod 49 Junior Poster

Write it Once and call it from the two places that you wanted to write. I used the following

 Private Sub dgv1_UserAddedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles dgv1.UserAddedRow
        bs.ResetBindings(False)
        **UpdateDatabase()**
    End Sub

    Private Sub dgv1_UserDeletedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles dgv1.UserDeletedRow
        bs.ResetBindings(False)
        **UpdateDatabase()**
    End Sub

   ** Private Sub UpdateDatabase()
        Try
            da.Update(ds, "SAMPLES")
        Catch ex As OleDbException
            MsgBox(ex.ToString)
        End Try
    End Sub**
kRod 49 Junior Poster

Do you actually have a Bridge_Number Field in your Table?
If you are using An Access DataBase I would first get the Query string into the "SQL View" of the Query Design window in MS-Access and test it. Also make sure you have spelled the Field names correctly. They have to be EXACT . You also have to have them in the correct order. You will need to make sure you are using the correct Data Type for each one.

kRod 49 Junior Poster

You could just put Exit Sub or Function when you get to the Else after the Error Message. You should break them up into 2 different Functions, A Labor Function and A Parts Price Function Return A Boolean and then when both Return True Execute the rest of your code.

kRod 49 Junior Poster

try this.

Provider := Microsoft.ACE.OLEDB.12.0;Data Source="C:\temp\MyExcel.xlsx";Extended Properties="Excel 12.0 Xml;HDR=YES;“;Jet OLEDB:Database Password=”";
kRod 49 Junior Poster

Try this

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;
Extended Properties="Excel 12.0 Xml;HDR=YES";

[Click Here](http://www.connectionstrings.com/excel-2007#ace-oledb-12-0)
kRod 49 Junior Poster

Hi cmstoner , what is the access database data type of your Business Phone field from the design view in ACCESS? If this is correct could you post the entire Insert command after you have built it?

kRod 49 Junior Poster

HibaPro, you can get the totalseconds of your timespan and use that to create a double then do the multiplaction. TimeSpan.TotalSeconds

kRod 49 Junior Poster

The text file with this post has one line of text and a newline. You can use either VBCRLF or VBNEWLINE

 Dim txt As String = My.Computer.FileSystem.ReadAllText(My.Computer.FileSystem.SpecialDirectories.Desktop & "\newLine.txt")

 If txt.Contains(vbNewLine) Then
            MsgBox(txt.IndexOf(vbNewLine))
        End If
kRod 49 Junior Poster

I may be off the edge of the map here but Why are you using the cmd.ExecuteReader to Insert values into a table when you should be using cmd.ExecuteNonQuery?

Nutster commented: I should have caught that. The wrong function is being called for an operation that does not return any rows. +3
AndreRet commented: Same here, should have seen that coming :) +12
kRod 49 Junior Poster

You want to call the DataGridVidew EndEdit() method when your cell leave event is fired.

kRod 49 Junior Poster

Well the first thing I see you are asking the sub to compare column 6 to column 4 are you aware datagridview columns are a zero based index so column 4 should be 3 and column 6 should be 5. Are you getting any errors or is nothing happening? Have you stepped thru each line of the sub to see if you are getting values into your variables.

kRod 49 Junior Poster

Your updated xmlwill only have 1 table now if that is what you are desiring. I ran the code and it displays the way I understand you want. I added a little updating code to it

Public Class Form1
    Dim bs As New BindingSource
    Dim editFlag As Boolean = False
    Dim filepath As String = "text.xml"
    Dim deflection_dataset As New DataSet

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            deflection_dataset.ReadXml(filepath)
            bs.DataSource = deflection_dataset.Tables(0)
            Deflections_datagrid.DataSource = bs
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub

    Private Sub btnSaveChanges_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveChanges.Click
        If editFlag Then
            Try
                deflection_dataset.WriteXml("Text.xml")
                editFlag = False
                MsgBox("Changes to the XML have been SAVED", MsgBoxStyle.Information, "SUCCESS")
            Catch ex As Exception
                MsgBox("CHANGES HAVE NOT BEEN SAVED", MsgBoxStyle.Critical, "FAILURE")
            End Try

        End If

    End Sub


    Private Sub Deflections_datagrid_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Deflections_datagrid.CellEndEdit
        editFlag = True
        bs.ResetBindings(False)

    End Sub
End Class
kRod 49 Junior Poster

One thing I see, your xml file when read into a dataset creates 4 data tables. I'm not sure what you want displayed, but if you want all the data from the xml file displayed in the datagridview you'll have to change the structure of your xml.

kRod 49 Junior Poster

Not to beat a dead horse, but you could just call this Sub like the following:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Call DoControls(Me)
    End Sub

    Private Sub DoControls(ByVal ctrlCont As Control)
        For Each ctrl As Control In ctrlCont.Controls
            If TypeOf ctrl Is CheckBox Then
                If TypeOf ctrl Is CheckBox AndAlso DirectCast(ctrl, CheckBox).Checked Then
                    If ctrl.Tag Is "Test" Then
                        DirectCast(ctrl, CheckBox).Checked = False
                    End If
                End If
            End If

            'If the ctrl has children, 
            'recall this Sub
            If ctrl.HasChildren Then
                DoControls(ctrl)
            End If
        Next
    End Sub
iFrolox commented: Worked :) Thank you +2
kRod 49 Junior Poster

Please disregard my previous post

Public Class Form1
  ''declare my array
  'Dim Pboxes() As PictureBox = {pb1, pb2, pb3, pb4, pb5, pb6, pb7, pb8}

  'Dim TBoxes() As TextBox = {tb1, tb2, tb3, tb4, tb5, tb6, tb7, tb8}

  'Used Lists
  Dim lstPBoxes As New List(Of PictureBox)
  Dim lstTBoxes As New List(Of TextBox)

  Private Sub Test()
    'call a function
    Call ClearBoxes()
  End Sub

  Public Sub ClearBoxes()

    'created so TextBox cooresponding
    'to the PictureBox could be accessed
    Dim i As Integer = 0

    'Loop the PictureBox List
    For Each lp In lstPBoxes
      lp = CType(lp, PictureBox) ' Needed so you have an object to test
      If Not lp.Image Is Nothing Then
        '(Pboxes(i).Image Is Nothing) Then '<<<<<< Nullref at this point
        i = lstPBoxes.IndexOf(lp)
        lp.Image.Dispose()
        lp.Image = Nothing
        CType(lstTBoxes(i), TextBox).Text = Nothing
      End If

    Next

  End Sub

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    'Fill PictureBox List
    lstPBoxes.Add(pb1)
    lstPBoxes.Add(pb2)
    lstPBoxes.Add(pb3)
    lstPBoxes.Add(pb4)
    lstPBoxes.Add(pb5)
    lstPBoxes.Add(pb6)
    lstPBoxes.Add(pb7)
    lstPBoxes.Add(pb8)
    lstPBoxes.Add(pb9)

    'Fill TextBox List
    lstTBoxes.Add(tb1)
    lstTBoxes.Add(tb2)
    lstTBoxes.Add(tb3)
    lstTBoxes.Add(tb4)
    lstTBoxes.Add(tb5)
    lstTBoxes.Add(tb6)
    lstTBoxes.Add(tb7)
    lstTBoxes.Add(tb8)


    Call Test()

  End Sub

End Class
kRod 49 Junior Poster

How did you get away with creating a Class with NO NAME? I just attempted to recreate your code and I had to assume you were using a Form as you had textboxes and pictureboxes and it will not let me in vs2008 sp1 create a class with no name. Anyway, assuming you are using a form You must create a PictureBox Object to test

For i As Integer = 0 To 7
      If Not CType(Pboxes(i), PictureBox) Is Nothing Then
        '      (Pboxes(i).Image Is Nothing) Then '<<<<<< Nullref at this point
        Pics(i).Image.Dispose()
        Pics(i).Image = Nothing
      End If
      Txt(i).Text = Nothing
    Next i
kRod 49 Junior Poster

Have you thought of using an XML file instead of the CSV. You could take advantage of the DataSet.Read and DataSet.Write methods.

themaj commented: dell +1
kRod 49 Junior Poster

What are the Primary Keys for your MS ACCESS Tables? Are they AutoNumbers?
Why are variables with names that sound like Numbers and Dates wrapped in single quotes?
If you are not entering all the values for all fields you need to specify the fields that the values correspond to, in the same order that appear in the MS ACCESS table.

You should set a Break Point at the start of your Sub btnConfirm_Click and step through it catch the values of sqlInsertOrder, sqlInsertProduct, and sqlInsertOrderProduct variables. When you copy them paste them into the Query Design Window of MS ACCESS and see if they execute.

kRod 49 Junior Poster

For insert query Click Here
For Executing The Command Click Here
You might want to have a go at this >>Click Here
Lots of helpful info on that site

kRod 49 Junior Poster

I found this Click Here Might be a solution. I would just call the Forms mouse enter and leave subs from the Panels mouse enter and leave subs.

kRod 49 Junior Poster

Hi Jim, I ran what you had set up in your test and tried TableLayoutPanel1.SendToBack and Me.BringToFront neither worked, Bummer.

Now for my question since you're getting the Panel MouseEnter event to fire isn't that the same as the Mouse entering the form or do you need the event Argument of the Form enter event. I’m just thinking out loud here.

kRod 49 Junior Poster

This is a simple function to determine if all the textboxes on a form have input or have not had there text property set to nothing. It creates a control variable, uses it to loop through all the control, when it finds a control that is of type TextBox it converts the variable to a TextBox That way it can check its Text Property. I know there are better explainations on MSDN about how it works.

Private Function ValidateInput() As Boolean

    Dim ret As Boolean = True

    For Each cnt In Me.Controls
      If TypeOf (cnt) Is TextBox Then
        If CType(cnt, TextBox).Text = "" Or CType(cnt, TextBox).Text Is Nothing Then
          ret = False
        End If
      End If
    Next

    Return ret

  End Function

Microsoft says >> Click Here

If your controls are in a Container on the Form you would have to iterate the Container to get the TextBoxes in the Container.

kRod 49 Junior Poster

Any chance we could see a sample of your CSV File? I am curious why you are tab delimiting and there are 2 tabs between Chocolate and the number 10 which I am guessing is the count. You could make your coding life a lot easier if you had a Orders Class and then add each order to a list(Of Orders). Or a simple DataTable with all your orders would be a more manageable. Also could you post the code you have so far I'd like to look at it and see what your thought process is?

kRod 49 Junior Poster

When your program is running how many forms would the user have open at one time? Are any of these Child forms? If they are not child forms you can use the following
Form Wide Variable Dim sef As frmDailySales >>frmDailySales is a Form.
Then in the event you want to open that form use

 Private Sub lnkEnterSales_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lnkEnterSales.LinkClicked

    If sef Is Nothing OrElse sef.IsDisposed = True Then
      sef = New frmDailySales
    End If

    If sef.Visible = False Then
      sef.Show()
      sef.whoCalled = Me 'Pass the Calling Form
      Me.Hide()
    End If

  End Sub

The frmDailySales will open. The form(frmSalesMain) that called frmDailySales will hide
The frmDailySales will have a variable>> Public whoCalled as Form
When you close frmDailySales

 Private Sub frmDailySales_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
    whoCalled.Show()
  End Sub

frmSalesMain will again be visible.

If I didn't explain this well enough let me know and I will help where you need it.

kRod 49 Junior Poster

You have no Single quotes around KMBPartNo

Dim SelectQry = "SELECT * FROM TblSupplierQuotes where TenderNo='" & Me.txtTenderRef.Text & "' AND KMBPartNo='" & Me.lbKMBPartNo.Text & "';"