JamesBowtell
Member
- Joined
- Feb 26, 2009
- Messages
- 16
- Programming Experience
- 3-5
Hey all,
i'm using Visual Basic 2008 express to create a software booking system with an SQL backend.
i have a search button on a form (frmUserDetails) that when clicked opens up a second form as a dialog box (frmSearch).
when i select an item from a datagrid thats in (frmSearch) the userID is placed in a variable (NuNameTB) the search form closes and the relevent details should be displayed in frmUserDetails.
but i'm getting an error that displays the following message within the frmsearch...(marked in red below)
Object reference not set to an instance of an object
if i add a new instance using Dim fromsoftwareloan As New frm_new_software_loan
the form closes and nothing is updated on the softwareloan form
form1 (frmUserDetails
form2 frmSearch
i'm using Visual Basic 2008 express to create a software booking system with an SQL backend.
i have a search button on a form (frmUserDetails) that when clicked opens up a second form as a dialog box (frmSearch).
when i select an item from a datagrid thats in (frmSearch) the userID is placed in a variable (NuNameTB) the search form closes and the relevent details should be displayed in frmUserDetails.
but i'm getting an error that displays the following message within the frmsearch...(marked in red below)
Object reference not set to an instance of an object
if i add a new instance using Dim fromsoftwareloan As New frm_new_software_loan
the form closes and nothing is updated on the softwareloan form
form1 (frmUserDetails
VB.NET:
Public Class frm_new_software_loan
Inherits System.Windows.Forms.Form
Public frmUserSearch As frm_user_search
Public userIDsearch As Integer
Private Sub ToolStripButtonSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonSearch.Click
Dim frmUserSearch As New frm_user_search
frmUserSearch.ShowDialog(Me)
End Sub
End Class
form2 frmSearch
VB.NET:
Public Class frm_user_search
Inherits System.Windows.Forms.Form
Public Shared NuNameTB As Integer
Public frmSoftwareLoan As frm_new_software_loan
Private Sub ButtonSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSearch.Click
If TextBoxSearch.Text = "" Then
MessageBox.Show("Please enter search criteria.", "Search", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Try
Me.Tbl_userTableAdapter.FillBySname(Me.UserDataSet.tbl_user, TextBoxSearch.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End If
End Sub
Public Sub Tbl_userDataGridView_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Tbl_userDataGridView.CellClick
NuNameTB = Me.Tbl_userDataGridView.Rows(e.RowIndex).Cells("DataGridViewTextBoxColumn1").Value
Try
'TODO: This line of code loads data into the 'SoftwareLookupDataSet.tbl_software' table. You can move, or remove it, as needed.
[COLOR="Red"]frmSoftwareLoan.Tbl_softwareTableAdapter.Fill(frmSoftwareLoan.SoftwareLookupDataSet.tbl_software)[/COLOR]
'TODO: This line of code loads data into the 'ITSoftwareLoansSDataSet.tbl_software_loan' table. You can move, or remove it, as needed.
frmSoftwareLoan.Tbl_software_loanTableAdapter.Fill(frmSoftwareLoan.ITSoftwareLoansSDataSet.tbl_software_loan)
'TODO: This line of code loads data into the 'ITSoftwareLoansSDataSet.tbl_user' table. You can move, or remove it, as needed.
frmSoftwareLoan.Tbl_userTableAdapter.FillByUserID(frmSoftwareLoan.ITSoftwareLoansSDataSet.tbl_user, NuNameTB)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
Me.Close()
End Sub
End Class