View Full Version : Renewed concatenation issue


SteveL
09-13-2008, 11:49 AM
For whatever reason I cannot get debugging to work. But let me say this... if I put the following code in an onclick event of the field, "txtCombinedCbxRecordInfo", which is the field I am trying to populate with the oncurrent event of the form, IT WORKS!!! Here is the code that is workig on the onclick event... (Please read below this copy/pasted code)

-=-=-=-=-=-=-=-
' Code to fill combine field with concatenated text
Dim rst As dao.Recordset
Dim txt As String

If Not Me.NewRecord Then
'open a recordset on the child records of the current record in Me
Set rst = CurrentDb.OpenRecordset( _
"SELECT [Core Sand Type] " & _
"FROM tblCbxNumberData " & _
"WHERE PartN = '" & Me.cboPartN & "'")

With rst
Do While Not .EOF
'if the field is non-null, concatenate
If Not IsNull(.Fields(0)) Then txt = txt & .Fields(0) & "/"
.MoveNext
Loop
.Close
End With
'drop the trailing "/"
If txt <> "" Then txt = Left(txt, Len(txt) - 1)
End If

Me.txtCombinedCbxRecordInfo = txt
' End of code to fill combine field with concatenated text
-=-=-=-=-=-=-
But when I put this same code in the on current event of the form along with other code I have had in there for some time, it does not work. Here is the complete on current event code...
-=-=-=-=-
'for developmental purposes
'If Len(Dir("C:\Company\General Shared Files\PRINTS\" & Me.txtPartN & "\*.*")) = 0 Then
' Me.chkprints = False
'Else
' Me.chkprints = True
'End If
'end of for developmental purposes

'for State Line purposes
If Len(Dir("\\Sbs1\Company\General Shared Files\PRINTS\" & Me.txtPartN & "\*.*")) = 0 Then
Me!chkprints = False
Else
Me!chkprints = True
End If
'end of for stateline purposes

Me.List1.Requery
Me.txtCPC = DSum("CPC", "tblCbxNumberData", "(PartN = '" & Me.txtPartN & "')")
Me.txtCBs = DCount("CPC", "tblCbxNumberData", "(PartN = '" & Me.txtPartN & "')")

' Code to fill combine field with concatenated text
Dim rst As dao.Recordset
Dim txt As String

If Not Me.NewRecord Then
'open a recordset on the child records of the current record in Me
Set rst = CurrentDb.OpenRecordset( _
"SELECT [Core Sand Type] " & _
"FROM tblCbxNumberData " & _
"WHERE PartN = '" & Me.cboPartN & "'")

With rst
Do While Not .EOF
'if the field is non-null, concatenate
If Not IsNull(.Fields(0)) Then txt = txt & .Fields(0) & "/"
.MoveNext
Loop
.Close
End With
'drop the trailing "/"
If txt <> "" Then txt = Left(txt, Len(txt) - 1)
End If

Me.txtCombinedCbxRecordInfo = txt
' End of code to fill combine field with concatenated text
-=-=-=-=-

Any thoughts?

RuralGuy
09-13-2008, 12:01 PM
Put a breakpoint in the OnCurrent code so you can single step the code and see what is going on.

Rich
09-13-2008, 12:15 PM
Why start another thread on an existing topic?

SteveL
09-13-2008, 01:21 PM
Rich,

I only did it because I thought the original topic was getting confusing. I am able to get this concatenation to work as I stated above with an onclick event of the field. But oncurrent of the form still does not work.

boblarson
09-13-2008, 01:23 PM
Do like RuralGuy suggests and put a breakpoint in the On Current code and follow it through to see what is happening (or not happening).

SteveL
09-13-2008, 01:27 PM
But I'm sorry... I do not know how to do this.

boblarson
09-13-2008, 01:28 PM
But I'm sorry... I do not know how to do this.

How about a picture:
http://www.btabdevelopment.com/main/QuickTutorials/Howtosetabreakpointtostepthroughcode/tabid/58/Default.aspx

SteveL
09-13-2008, 01:41 PM
My f8 key does nothing.

boblarson
09-13-2008, 01:53 PM
My f8 key does nothing.

Did you open the form in form view first so that the On Current event would fire? The event has to fire before it breaks for the breakpoint.

SteveL
09-13-2008, 01:57 PM
Yes. I did.

boblarson
09-13-2008, 01:59 PM
Can you post your db?

How to post a database to AWF (http://www.access-programmers.co.uk/forums/showthread.php?t=140587)

SteveL
09-13-2008, 02:02 PM
I can zip it (FE and BE) and post. But I'll have to also write a long explanation of what I am trying to do. Is that ok?

boblarson
09-13-2008, 02:04 PM
I can zip it (FE and BE) and post. But I'll have to also write a long explanation of what I am trying to do. Is that ok?

I think it might be faster to do it that way, at this point.

SteveL
09-13-2008, 02:08 PM
My zip file is about 1.5 MB.

boblarson
09-13-2008, 02:09 PM
My zip file is about 1.5 MB.

For the FE, BE or Both?

boblarson
09-13-2008, 02:10 PM
Oh, and did you remember to use COMPACT and REPAIR on both FE and BE before zipping?

SteveL
09-13-2008, 02:10 PM
Both zipped together.

SteveL
09-13-2008, 02:11 PM
Yes, I did C&R first.

boblarson
09-13-2008, 02:11 PM
Both zipped together.

Try making sure to compact and repair first and then zip each individually and upload each individually.

SteveL
09-13-2008, 02:13 PM
The FE alone is 1.3MB.

boblarson
09-13-2008, 02:14 PM
I PM'd my email address to you.

SteveL
09-13-2008, 02:20 PM
Bob, I just emailed to you.

PS - I see you play several instruments. I play guitar. Elecric and acoustics blues is a passion.

--Steve

boblarson
09-13-2008, 02:21 PM
Bob, I just emailed to you.

PS - I see you play several instruments. I play guitar. Elecric and acoustics blues is a passion.

--Steve

We have another problem. I tried opening it but it would appear that it is a secured database and I don't have the mdw file that goes with it.

SteveL
09-13-2008, 02:24 PM
Just emailed to you.

raskew
09-13-2008, 04:15 PM
This thread has got to set a new world's record for the # of posts that go absolutely nowhere.

Bob

P.S.: Maybe we could all become penpals and use this forum/thread to chat about our musical experiences.

boblarson
09-14-2008, 03:22 PM
Just emailed to you.

Seems to work for me. What version of Access are you using and what service pack level?

SteveL
09-15-2008, 02:11 AM
Access 2003, SP3.

boblarson
09-15-2008, 05:07 AM
Access 2003, SP3.

Was afraid of that. SP3 has issues. Have you applied the post SP3 hotfix yet? If not, I would suggest doing so:

http://support.microsoft.com/kb/945674

SteveL
09-15-2008, 03:38 PM
Bob, I applied the hotfix but it still does not work. If I click on the concatenated field the combined text appears. But if I clear the field, close the form, relaunch the form, and go to the tab, the field is empty. ???