I have an invoice form using a data grid (DGVInvoice). When I start to enter a description, this shows another grid in the same Form (DGVMatches) that shows all matches from the Invoice/Description field in the database. Clicking any of the matches updates the DGVInvoice description field.
This works perfectly on Line 1 of the invoice, but when I enter a description on subsequent lines, no matches are displayed in DGVMatches (although the DGVMatches header shows the search term correctly).
Code in DGVInvoice to call DGVMatches:
Code in DGVMatches to fill the DGVInvoice Description field:Code:Private Sub ShowMatches() ' @@ Fetch Descriptions from LineEntry table Dim pSQL As String = "SELECT DISTINCT [Desc] FROM LineEntry WHERE [Desc] LIKE '" & mCellContent & "%' ORDER BY [Desc] " Dim m_Datatable As New DataTable Using cnn As New OleDbConnection(gs_Connection) cnn.Open() Using dad As New OleDbDataAdapter(pSQL, cnn) dad.Fill(m_Datatable) dad.Dispose() End Using cnn.Close() End Using GbMatching.Text = "Matching entries for '" & mCellContent & "'" If m_Datatable.Rows.Count = 0 Then ' ** No data GbMatching.Visible = False Else With DgvMatches .DataSource = m_Datatable GbMatching.Visible = True .Columns(0).Width = 360 .Columns(0).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft ' @@ Aligns cells .Refresh() End With m_Datatable = Nothing End If End Sub
Can anyone help with this?Code:Private Sub DgvMatches_Click(sender As Object, e As EventArgs) Handles DgvMatches.Click With DgvInvoice .CurrentCell.Value = DgvMatches.CurrentCell.Value DgvInvoice.BeginEdit(False) End With GbMatching.Visible = False mMatchFound = True DgvMatches.Dispose() End Sub




Reply With Quote
