Heres my problem. I have a form name frmOwner and the user uses this to search for various information about a company. On the current record the user wants to view EDI setup information so they select an option from a menu and another form is displayed (frmMapping). frmMapping takes the data from frmOwner.txtOwnerID.text and popluates an Adodc1 control, that is used to populate a datagrid (dgResults). This works fine, but my problem is when I close the frmMapping and go back to frmOwner and go to another record and want to view EDI setup information the datagrid on frmOwner still displays the previous record EDI information, so I have close the form and open it again to display the new record EDI's information.
I have attached the code for the frmMapping, any thoughs on how to correct this behavior. Thanks
Sub FillAdodcControl()
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=WITCO;Data Source=SQLDEV2"
Adodc1.RecordSource = "select EDI10200.EDIMPID, EDI10200.OwnerID, EDI10200.VendorID, EDI10200.Channel, EDI10200.IsProduction, EDI10200.StartsOn, EDI10200.EndsOn, PM00200.VendName FROM EDI10200 left join PM00200 on PM00200.VendorID = EDI10200.VendorID where EDI10200.OwnerID='" & frmOwner.txtOwnerID.Text & "'"
Adodc1.Refresh
Set dgResults.DataSource = Adodc1
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub Form_Load()
Call FillAdodcControl
Call FormatGrid
End Sub
'===============================================================================================
'used to format the datagrid on form frmEDIWorksheet
'this fixed the issues aftter updates,deletes and inserts the datagrid would lose its format
'===============================================================================================
Sub FormatGrid()
dgResults.Columns.Item(0).Width = 750 'EMPID
dgResults.Columns.Item(1).Width = 900 'OwnerID
dgResults.Columns.Item(2).Width = 900 'VendorID
dgResults.Columns.Item(3).Width = 675 'Channel
dgResults.Columns.Item(4).Width = 1000 'IsProduction
dgResults.Columns.Item(5).Width = 1000 'StartsOn
dgResults.Columns.Item(6).Width = 1000 'EndOn
dgResults.Columns.Item(7).Width = 3500 'VendName
'Variable for Format
Dim stdYesNo As StdFormat.StdDataFormat
'DataGridFormat
Set stdYesNo = New StdFormat.StdDataFormat
stdYesNo.Type = fmtBoolean
stdYesNo.TrueValue = "YES" 'display value for True ( -1)
stdYesNo.FalseValue = "NO" 'display value for False (0)
Set dgResults.Columns(4).DataFormat = stdYesNo
End Sub
'=================================================================================================
'= When user clicks datagrid display the record in the fields (current record section)
'=================================================================================================
Private Sub dgResults_SelChange(Cancel As Integer)
dgResults.SelStart = 1
'lblEDIMPID.Caption = dgResults.Columns(0).Text 'not being displayed
lblOwnerID.Caption = dgResults.Columns(1).Text
txtVendorID.Text = dgResults.Columns(2).Text
txtChannel.Text = dgResults.Columns(3).Text
Dim chkIsProduct As Integer
chkIsProduct = dgResults.Columns(4).Value
If chkIsProduct = 0 And chkIsProduct <> 2 Then
chkIsProduction.Value = 0 'unchecked
Else
chkIsProduction.Value = 1 'checked
End If
dtpStartsOn.Value = dgResults.Columns(5).Text
dtpEndsOn.Value = dgResults.Columns(6).Text
End Sub