Thanks Rob, that's really helpful.
This is the function I've come up with using it:
Public Function splitpid(CombinedID As String)
Dim SheetID As String
Dim ParcelID As String
SheetID = Left(CombinedID, 6)
ParcelID = Right(CombinedID, 4)
End Function
How can I pass the SheetID and ParcelID back into each stage of the
following loop: (snippet of code follows)
'Filling objWord object with data
With objWord
.Visible = True
.Documents.Open (strDocPath)
'Inserting SBI
.ActiveDocument.Bookmarks("bmSBI").Select
If IsNull(Forms!frmMainData!SBI) Then SBIno = "" Else: SBIno =
(CStr(Forms!frmMainData!SBI))
.Selection.Text = SBIno
'Navigate to first record (field)
Forms!frmMainData!subFields.SetFocus
DoCmd.GoToRecord , , acFirst
'Jump to each bookmark in the word doc and insert corresponding
DB field data
'Checks to make sure fields aren't Null before passing data to
Word document
'Navigate to 1st record (field)
.ActiveDocument.Bookmarks("bmOldPID").Select
If IsNull(Forms!frmMainData!subFields!NewParcelID) Then
OldPID1 = "" Else: OldPID1 = (CStr(Forms!frmMainData!subFields!NewParcelID))
OldPID1 = OldPID1 & "Hello"
.Selection.Text = OldPID1
.ActiveDocument.Bookmarks("bmNewPID").Select
If IsNull(Forms!frmMainData!subFields!OldParcelID) Then
NewPID1 = "" Else: NewPID1 = (CStr(Forms!frmMainData!subFields!OldParcelID))
.Selection.Text = NewPID1
.ActiveDocument.Bookmarks("bmFieldSize").Select
If IsNull(Forms!frmMainData!subFields!FieldSize) Then
FieldSize1 = "" Else: FieldSize1 =
(CStr(Forms!frmMainData!subFields!FieldSize))
.Selection.Text = FieldSize1
'Navigate to 2nd record (field)
Forms!frmMainData!subFields.SetFocus
DoCmd.GoToRecord , , acNext
.ActiveDocument.Bookmarks("bmOldPID2").Select
If IsNull(Forms!frmMainData!subFields!New
"Rob Meade" wrote:
"Andy C Matthews" wrote ...
a ten-digit string such as TQ03409954, needs to be split into
SHEET ID (the first six characters) and PARCEL ID (the last 4) e.g. TQ0340
9954. Can anyone help me? I'm messing around using For loops and the
Split()
function, but to no avail.
Dim CombinedID As String
Dim SheetID As String
Dim ParchelID As String
CombinedID = "TQ03409954"
SheetID = Left(CombinedID, 6)
ParcelID = Right(CombinedID, 4)
Hope that helps..
Regards
Rob