Passing value to subform using SQL
Hi All
This works fine with Access Db but having problem when connection with SQL db
I've two forms
Callsheet
Callsheet subform
Selecting a value form Combobox [RepList] 'Sales representative list is populating list box [NearCustomer]
List Box: Near Customer Properties
Name: NearCustomers
Row Source Type:Table/View/StoredProc
Row Source: CustomerLocationList [stored proc]
Now when click on any list box Item run this piece of code
Private Sub NearCustomers_DblClick(Cancel As Integer)
Dim r As New ADODB.Recordset '[ok]
On Error GoTo nc_err'[ok]
r.Open "CallSheet", CurrentProject.Connection, adOpenKeyset, adLockOptimistic'[ok]
r.AddNew'[ok]
r!CID = Me!NearCustomers'[ok]
r!Rep = RepList'[ok]
r!TDate = Date'[ok]
r!ApptTime = #12:00:00 AM#'[ok]
r!User = CUser()'[ok]
r!SDate = Now()'[ok]
r.Update'[ok]
r.Close'[ok]
Me!CallSub.Requery [Error here code in next sub]
nc_exit:'[ok]
Exit Sub'[ok]
nc_err:'[ok]
e Err.number, Err.Description'[ok]
Resume nc_exit'[ok]
End Sub'[ok]
Private Sub Form_Current()
Dim r As New ADODB.Recordset, criteria As String
On Error Resume Next
If IsNull(Me!CID) Then Exit Sub [it doesnt have any value here Me!CID is null but same piece of code with Access db work fine here]
r.Open "SELECT APC FROM Customers WHERE CID='" & Me!CID & "'", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
If Not r.EOF Then
If IsNull(r!APC) Or Len(r!APC) < 2 Then
Me.Parent.PostcodeSearch = Null
Else
Me.Parent.PostcodeSearch = Left$(r!APC, 2)
End If
Me.Parent.AddrSearch = Null
Me.Parent.NearCustomers.Requery
End If
r.Close
flag = False
End Sub
|