question

Kennyqui-0889 avatar image
0 Votes"
Kennyqui-0889 asked Kennyqui-0889 commented

What is the problem, why i cant populate textbox or datetimepicker when i click the rows or column in datagridview

Heres the code below. Im using ms visual studio 2010 and ms access database.

Private Sub SelectIssueBook(ByVal Name As String)
' QUERY Issue BOOK
Access.AddParam("@issue", Name)
Access.ExecQuery("SELECT Issue_No, Status, First_Name, Last_Name, MI, Year_Section, Book_Title, Borrow_Date FROM db_Issue WHERE First_Name=@issue ")

     ' REPORT & ABORT ON ERRORS OR NO RECORDS FOUND
     If Not String.IsNullOrEmpty(True) = False OrElse Access.RecordCount < 1 Then Exit Sub


     ' GET FIRST ROW FOUND
     Dim R As DataRow = Access.DBDT.Rows(0)

     ' POPULATE TEXTBOXES WITH DATA
     IssueNo.Text = R("Issue_No").ToString
     Status.Text = R("Status").ToString
     FirstName.Text = R("First_Name").ToString
     LastName.Text = R("Last_Name").ToString
     MI.Text = R("MI").ToString
     YearSection.Text = R("Year_Section").ToString
     BookTitle.Text = R("Book_Title").ToString
     DateTimePicker1.Value = R("Borrow_Date").ToString


     ' ENABLE DELETE
     BtnDelete.Enabled = True

 End Sub
dotnet-visual-basicoffice-access-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
1 Vote"
Viorel-1 answered Kennyqui-0889 commented

Try removing this fragment: Not String.IsNullOrEmpty(True) = False OrElse.

Check that the query returns data, and the shown code, which populates the controls, is executed.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I try to remove that and when I click the row ,the first row only populate but when I click other rows it will not change the data populate in textbook and datetimepicker, the first rows only that populate.

0 Votes 0 ·

Dit you check if the 'ByVal Name As String' variable contain the correct value according to the clicked row?

If this is not a unique value that can be used to identify the row, maybe it is better to use some other values, such as Issue_No. If you get it from the current clicked row and it is unique, you can use 'WHERE Issue_No=@issue' instead of 'WHERE First_Name=@issue'.


0 Votes 0 ·

Thank you so much because of you i find the problem and now my application is running perfectly.

0 Votes 0 ·