Gasman
Enthusiastic Amateur
- Local time
- Today, 06:00
- Joined
- Sep 21, 2011
- Messages
- 17,491
Hi guys,
This morning I thought I'd investigate disconnected recordsets as it was recommended to me a good while back when I created a db for work colleagues, but did not have the time to investigate any further.
I discovered a site this morning that gave a good example using the Northwind DB which I have in my current workplace, so I could fiddle with that in my own time.
I cannot find the link any more but the code looks like below. My changes are in red.
However the original code was using fields with no spaces and were also incorrect. This is the code behind the save button, that I have only commented out for now
What I am trying to find out is the syntax I must use when the filenames have spaces as the Northwind db currently has?
I've tried ![Last Name], !"Last Name", "!Last Name", !["Last Name"] with no success.
What is the correct syntax for using the ! with field names that contain spaces?, or a better way to reference them.
TIA
This morning I thought I'd investigate disconnected recordsets as it was recommended to me a good while back when I created a db for work colleagues, but did not have the time to investigate any further.
I discovered a site this morning that gave a good example using the Northwind DB which I have in my current workplace, so I could fiddle with that in my own time.
I cannot find the link any more but the code looks like below. My changes are in red.
Code:
Private Sub cboCompanyName_AfterUpdate()
'Populate form with filtered results.
On Error GoTo ErrHandler
Dim strCriteria As String
strCriteria = "ID = '" & Me!cboCompanyName.Value & "'"
' strCriteria = "CustomerID = " & Me!cboCompanyName.Value
Debug.Print strCriteria
With CustomerDisconnectedRS
If Not (.EOF) Then
.Find strCriteria
Me.txtCustomerID = !ID
[COLOR="Red"]Me.txtContactName = ![Last Name]
Me.txtContactTitle = [Job Title][/COLOR]
Me.txtAddress = !Address
Me.txtCity = !City
'Me.txtRegion = !Region
'Me.txtCountry = !Country
'Me.txtPhone = !Phone
'Me.txtFax = !Fax
End If
End With
Exit Sub
However the original code was using fields with no spaces and were also incorrect. This is the code behind the save button, that I have only commented out for now
Code:
Private Sub cmdSave_Click()
On Error GoTo ErrHandler:
With CustomerDisconnectedRS
'!ID = Me.txtCustomerID
!ContactName = Me.txtContactName
!ContactTitle = Me.txtContactTitle
!Address = Me.txtAddress
!City = Me.txtCity
'!Region = Me.txtRegion
'!Country = Me.txtCountry
'!Phone = Me.txtPhone
'!Fax = Me.txtFax
End With
cmdUpdateServer.Enabled = True
Exit Sub
ErrHandler:
MsgBox Err.Number & ": " & Err.Description, vbOKOnly, "Error"
End Sub
What I am trying to find out is the syntax I must use when the filenames have spaces as the Northwind db currently has?
I've tried ![Last Name], !"Last Name", "!Last Name", !["Last Name"] with no success.
What is the correct syntax for using the ! with field names that contain spaces?, or a better way to reference them.
TIA