Dim rs As ADODB.Recordset
Dim SQLstmt As String
Dim cname As String
Set rs = New ADODB.Recordset
If Not IsNull(Me!custcode) Then
SQLstmt = "SELECT * FROM [cust-brkr]" _
& " Where [cust-brkr]![customer-code] = '" & Me!custcode & "'"
MsgBox (SQLstmt)
rs.ActiveConnection = CurrentProject.Connection
rs.Source = SQLstmt
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Open
If Not rs.EOF Then
Me![custname] = rs![customer-name] ‘该语句无法给custname(是个combobox赋值)
Me![address] = rs![address]
Me![phone] = rs![phone-number]
Me![country-code] = rs![country-code]
Me![cust-desc] = rs![customer-description]
Me![cust-cont-name] = rs![customer-contract-name]
Me![ship-dates] = rs![shipping-days]
End If
rs.Close
End If