QUOTE(jayman9 @ 16 Dec, 2007 - 01:17 PM)

We are going to need to see more code.
Here it is:
CODE
From the Call button on the Contacts form
Private Sub btnEditCalls_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditCalls.Click
Dim frmCalls As New CallsForm(sCN)
frmCalls.ContactID = txtContactID.Text 'push in the show ID
frmCalls.txtFirstName.Text = txtFirstName.Text
frmCalls.txtLastName.Text = txtLastName.Text
frmCalls.ConnString = sCN
frmCalls.ShowDialog()
frmCalls.Dispose()
'refresh contacts
Call cmgrCalls_PositionChanged(Me, e)
End Sub
From the Calls Form
Dim m_SCN As String 'connections string
Dim m_ContactID As Integer 'show ID
Dim oCalls As New clsCalls(m_SCN)
Dim dsCalls As DataSet
Dim bFormLoaded As Boolean
Dim WithEvents cmgrCalls As CurrencyManager
Dim iMaxSeason As Integer
Friend WriteOnly Property ConnString() As String
Set(ByVal value As String)
m_SCN = value
End Set
End Property
Friend WriteOnly Property ContactID() As Integer
Set(ByVal value As Integer)
m_ContactID = value
End Set
End Property
Private Sub CallsForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'get the episodes for a Show
dsCalls = oCalls.GetData(m_ContactID)
Call DoBinding()
bFormLoaded = True
End Sub
Public Sub New(ByVal ConnString As String)
m_SCN = ConnString
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
Private Sub DoBinding()
cmgrCalls = CType(Me.BindingContext(dsCalls.Tables(0)), CurrencyManager)
'Take care of defaults
If dsCalls.Tables(0).Columns("CallDate").DefaultValue Is System.DBNull.Value Then
dsCalls.Tables(0).Columns("CallDate").DefaultValue = Now
End If
If dsCalls.Tables(0).Columns("CallTime").DefaultValue Is System.DBNull.Value Then
dsCalls.Tables(0).Columns("CallTime").DefaultValue = False
End If
'bind the controls
grdCalls.DataSource = dsCalls.Tables(0)
cboCallID.DataSource = dsCalls.Tables(0)
cboCallID.DisplayMember = "CallID"
cboCallID.ValueMember = "CallID"
txtCallID.DataBindings.Add("Text", dsCalls.Tables(0), "CallID")
txtContactID.DataBindings.Add("Text", dsCalls.Tables(0), "ContactID")
dtpCallDate.DataBindings.Add("Text", dsCalls.Tables(0), "CallDate")
dtpCallTime.DataBindings.Add("Text", dsCalls.Tables(0), "CallTime")
txtSubject.DataBindings.Add("Text", dsCalls.Tables(0), "Subject")
txtNotes.DataBindings.Add("Text", dsCalls.Tables(0), "Notes")
End Sub
Private Sub Unbind()
'unbind controls to refresh the data
cmgrCalls = Nothing
cboCallID.DataSource = Nothing
txtCallID.DataBindings.Clear()
txtContactID.DataBindings.Clear()
dtpCallDate.DataBindings.Clear()
dtpCallTime.DataBindings.Clear()
txtSubject.DataBindings.Clear()
txtNotes.DataBindings.Clear()
grdCalls.DataSource = Nothing
End Sub
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
'add a new record
cmgrCalls.AddNew()
Dim rw As DataRowView
rw = cmgrCalls.Current
rw.Item("ContactID") = m_ContactID
dtpCallDate.Focus()
End Sub
Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
'go to first record
cmgrCalls.Position = 0
End Sub
Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click
'go to previous record
cmgrCalls.Position -= 1
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
'go to next record
cmgrCalls.Position += 1
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
'go to previous record
cmgrCalls.Position = cmgrCalls.Count - 1
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
'delete an episode
cmgrCalls.EndCurrentEdit()
Dim rwCalls As Data.DataRowView = cmgrCalls.Current
rwCalls.Delete()
End Sub
Private Sub btSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSave.Click
Dim dsChanges As DataSet
Dim sMsg As String
Dim dtErrors As DataTable
Dim oCalls As New clsCalls(m_SCN)
cmgrCalls.EndCurrentEdit()
dsChanges = dsCalls.GetChanges 'Get all rows that have been changed
slblMsg.Text = oCalls.SaveData(dsChanges, dtErrors)
If Not dtErrors Is Nothing Then
'no errors
dsCalls.AcceptChanges()
Else
'show the users the error rows
End If
'reload data
Call Unbind()
dsCalls.Clear()
dsCalls = oCalls.GetData
Call DoBinding()
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
'cancel a change
cmgrCalls.CancelCurrentEdit()
End Sub
Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelAll.Click
'Cancel all changes
cmgrCalls.CancelCurrentEdit()
dsCalls.RejectChanges()
End Sub
Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclose.Click
Me.Close()
End Sub
End Class
From the Calls Class itself
Public Class clsCalls
Dim m_sCN As String 'Connection string for use by this class
Dim dtErrors As New DataTable
Private m_oDS As DataSet '//--- The DataSet to use
Private WithEvents m_oDA As OleDb.OleDbDataAdapter '//--- The DataAdapter that links the DataSet to the Connection
Private m_sClassName As String = "Calls" '//--- The name of the class
'Private sCN As String 'conncection String
Private m_oCn As New OleDb.OleDbConnection '//--- The Connection the database
Dim sSQL As String = ""
Dim oSelCmd As OleDb.OleDbCommand
'Dim oInsCmd As OleDb.OleDbCommand
'Dim oUpdCmd As OleDb.OleDbCommand
'Dim oDelCmd As OleDb.OleDbCommand
Public Sub New(ByVal sConn As String)
m_sCN = sConn
m_oCn.ConnectionString = m_sCN
'---------------------------------------------------------
'--- Create and set up the DataAdapter
'---------------------------------------------------------
m_oDA = New OleDb.OleDbDataAdapter
With m_oDA
.SelectCommand = CreateDASelectCommand()
'.UpdateCommand = CreateDAUpdateCommand()
'.DeleteCommand = CreateDADeleteCommand()
'.InsertCommand = CreateDAInsertCommand()
End With
Dim cmdBld As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(m_oDA)
End Sub
Private Function CreateDASelectCommand() As OleDb.OleDbCommand
Dim sSQL As String 'string with SQL
Dim cmd As New OleDb.OleDbCommand(sSQL, m_oCn) 'command object
'---------------------------------------------------------
'--- Set up the SELECT Command
'---------------------------------------------------------
sSQL = "select CallID, ContactID, CallDate, CallTime, Subject, Notes from tblCalls" 'SQL to use
'sSQL &= " where ShowID = " & iShowID
cmd.CommandText = sSQL
cmd.CommandType = CommandType.Text 'this is SQL rather than a stored procedure
Return cmd 'return the full command
End Function
Public Function SaveData(ByVal oDS As DataSet, ByRef dtErrors As DataTable) As String
Dim sMsg As String
Dim lRecsAffected As Long
'---------------------------------------------------------
'//--- Save the data
'---------------------------------------------------------
Try
'--- Open the conection manually
m_oCn.Open()
'--- Make all database changes
lRecsAffected = m_oDA.Update(oDS, m_sClassName)
'--- Set the message for the user
sMsg = lRecsAffected & " Record(s) Were Updated"
Catch e As Exception
sMsg = "Records were not updated" & vbCrLf & e.Message.ToString()
Finally
'--- Close the connection that we manually opened
m_oCn.Close()
SaveData = sMsg
End Try
End Function
'//------------------------------------------------------------------------------------------------------------
'// Public Method
'// Overloaded: Yes
'// Parameters: None
'// Return Value: DataSet
'// Purpose: Retrieves all episodes.
'//------------------------------------------------------------------------------------------------------------
Public Function GetData() As DataSet
''--- Create a new DataSet
m_oCn.Open()
m_oDS = New DataSet
''--- Fill the DataSet with the Customers
m_oDA.Fill(m_oDS, m_sClassName)
m_oCn.Close()
''//--- Return the DataSet
Return m_oDS
End Function
'//------------------------------------------------------------------------------------------------------------
'// Public Method
'// Overloaded: Yes
'// Parameters: ContactID
'// Return Value: DataSet
'// Purpose: Retrieves all calls for a given contact.
'//------------------------------------------------------------------------------------------------------------
Public Function GetData(ByVal iContactID As Integer) As DataSet
Dim sSQLOrig As String = "" 'The original SQL used for all records
Try
''--- Create a new DataSet
sSQLOrig = m_oDA.SelectCommand.CommandText
m_oDA.SelectCommand.CommandText &= " where ContactID = " & iContactID.ToString
m_oCn.Open()
m_oDS = New DataSet
''--- Fill the DataSet with the Customers
m_oDA.Fill(m_oDS, m_sClassName)
m_oCn.Close()
''//--- Return the DataSet
Return m_oDS
Catch ex As Exception
Throw ex
Finally
'reset SQL back to generic 'Grab Everything'
m_oDA.SelectCommand.CommandText = sSQLOrig
End Try
End Function
Friend Function GetNumOfCalls(ByVal ContactID As Integer) As Integer
'Input - the ID of the show we want to count episodes for
'output - the number of episodes for a given show
Dim iReturn As Integer 'variable to stash return information
Dim sSQL As String
sSQL = "select count(CallID) from tblCalls where ContactID = " & ContactID
Dim cn As New OleDb.OleDbConnection(m_sCN)
Dim cmd As New OleDb.OleDbCommand(sSQL, cn)
cn.Open()
Dim reader As OleDb.OleDbDataReader = cmd.ExecuteReader()
While reader.Read()
iReturn = reader.GetInt32(0)
End While
reader.Close()
cn.Close()
'cleanup
reader = Nothing
cmd.Dispose()
cn.Dispose()
Return iReturn 'return the couont of episodes
End Function
End Class
I've also added the entire file just in case