Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Event after update of last record in subform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robin S. - 31 Jul 2007 15:37 GMT
I have a subform which lists specifications for a product. The user
enters the specification, hits enter, and the code below concentenates
the name of the spec, the value, and the prefix/suffix as required.
Multiple specs are strung together into a single memo field.

Everything works fine until the last record on the subform. The event
fires, but (I assume) because the last record does not lose the focus,
the value of the last spec is not updated in the concentenated memo
field.

If the code is run after focus is moved off the last spec, the spec
updates as it should.

Any thoughts on how to do this simply? I can't detect when enter is
used after updating the last record (as opposed to using enter on the
second last record, moving to the last record, and then firing the
enter event - which is what seems to happen naturally).

Thoughts? Code below sig line.

Regards,

Robin

Private Sub UpdateConcSpecs()
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim varConcat As Variant

'Concentenated specification proceedure

Set db = CurrentDb
strSQL = "SELECT AutoProductNumber, ConcValue FROM
qryProClassJoinDetails WHERE AutoProductNumber = " &
Eval("Forms.frmProductSpecifications.AutoProductNumber")
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
varConcat = Null
'Make sure records exist
With rs
   If .RecordCount <> 0 Then
   'start concatenating records
       Do While Not rs.EOF
       varConcat = varConcat & rs("ConcValue") & "<br> "
       .MoveNext
       Loop
   End If
End With

Forms!frmProductSpecifications.ConcSpecDescription = varConcat

Exit_UpdateConcSpec:
   Set rs = Nothing: Set db = Nothing
   Exit Sub

Err_UpdateConcSpecs:
Resume Exit_UpdateConcSpec
Jeff Boyce - 31 Jul 2007 15:45 GMT
I'm not sure I can envision a way to have Access "know" when <Enter> means
"I'm all done entering specs", vs. "I'm done with THIS spec, start me a new
one".

Another approach might be to force the user to move elsewhere, either to a
new "spec" row, or some place else.  You could do this by setting the
"Cycle" property to "Current Record".  That way, the user would control when
the spec was finished, rather than simply hitting <Enter>.

Regards

Jeff Boyce
Microsoft Office/Access MVP

>I have a subform which lists specifications for a product. The user
> enters the specification, hits enter, and the code below concentenates
[quoted text clipped - 53 lines]
> Err_UpdateConcSpecs:
> Resume Exit_UpdateConcSpec
Robin S. - 31 Jul 2007 16:36 GMT
> I'm not sure I can envision a way to have Access "know" when <Enter> means
> "I'm all done entering specs", vs. "I'm done with THIS spec, start me a new
> one".

Jeff,

My bad. I didn't claify. The subform does not allow new entries. All
of the records were created when the product was created. They just
sit there with a field blank for each spec until the user enters the
value.

I just wanted to be able to fire an event when the user hits [Enter]
after editing the last record. Ideally, I could move the focus to the
first record (thus moving off the last record, and allowing the
concentenating code to work correctly).

My major issue is that the [Enter] event for both the second last
record and the last record seems to occure interchangeably. I can't
tell if the user was already on the last record, or if they were on
the second last record.

I was comparing the Me.CurrentRecord and
RecordsetClone.AbsolutePosition (after .MoveLast) to detect which
record has focus.

> Another approach might be to force the user to move elsewhere, either to a
> new "spec" row, or some place else.  You could do this by setting the
> "Cycle" property to "Current Record".  That way, the user would control when
> the spec was finished, rather than simply hitting <Enter>.

I want to keep the keystrokes to an absolute minimum. We'll be
entering thousands of products and every keystroke is important.

Thanks very much for your time.

Regards,

Robin
Dale Fye - 31 Jul 2007 19:12 GMT
Robin,

Can't say that I would encourage this train of thought.  I never like to use
a memo field to store data that should logically be in some other form of
details table (in this case tbl_SomethingSpecDetails).

However, if you are set on using this technique, I would add a command
button to the subforms footer that says something like "Post records", which
posts your records and then clears out the Specs subform.  This way, the user
can post the Specs at any time, not  just after he has made changes to the
"last" record on the subform.

HTH
Dale

Signature

Email address is not valid.
Please reply to newsgroup only.

> > I'm not sure I can envision a way to have Access "know" when <Enter> means
> > "I'm all done entering specs", vs. "I'm done with THIS spec, start me a new
[quoted text clipped - 34 lines]
>
> Robin
Jeff Boyce - 31 Jul 2007 21:06 GMT
Robin

I'm with Dale on what seems to be the notion of "stuffing" a lot of items
into a single memo field.  Why not use a one-to-many relationship and store
each item in its own record?

Regards

Jeff Boyce
Microsoft Office/Access MVP

> Robin,
>
[quoted text clipped - 56 lines]
>>
>> Robin
Dale Fye - 31 Jul 2007 21:56 GMT
Robin,

Just to go another step in this discussion.  I have been known to "display"
information in a textbox similiar to what you are describing, despite the
fact that it is stored in a details table.

For example, a client enters information into a two line textbox on a
continuous form for each observation that they make, but when I display the
main record, I have a large textbox (locked) which concatenates all of the
text from the separate records into a single "document" which is easier to
read than the continuous form.

If they want to edit the text, they click a button and the textbox is
replaced with the continuous form.

Dale

Signature

Email address is not valid.
Please reply to newsgroup only.

> Robin
>
[quoted text clipped - 67 lines]
> >>
> >> Robin
Robin S. - 31 Jul 2007 22:15 GMT
> Robin
>
> I'm with Dale on what seems to be the notion of "stuffing" a lot of items
> into a single memo field.  Why not use a one-to-many relationship and store
> each item in its own record?

Jeff and Dale,

You're certainly right, and each specification is actually stored
exactly as you've suggested.

The problem is that I have to output a file for web shopping cart
software, and I don't have control over how that database works. These
specs are concentencated into one "Description" field.

I like the idea of running the code just before the form is closed.
That'll do just fine.

Thanks for your help.

Regards,

Robin
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.