Phew...ok first to answer your points:
Highlighting (selecting) records, for the query to append, I guess wherever
the curser (row) is will do this regardless of it being in one field or the
next in the row, but would like the row (all fields) to be selected
(highlighted by default) when tabbed into the datasheet, just looks & feels
better.
The subdata sheet reference I made is in fact a select query with criteria
"like xyz*" from a combo box on the form to the title field in the query,
made into form datasheet & placed into the form, the refresh button
refreshes the datasheet if the user wants to search again on a new title
etc. It's a simple search "title" & append "record" form.
Ok accepted what about a sub-datasheet?, I have seen forms written in vb I
think that have this as default in datasheets in a form. I did make an forum
enquiry earlier on this, its just that my form has changed considerably
since so I re-posted, just to give you that previous posting answer here:
****************************************************************************
How to open a form that automatically selects a) a row.
ANSWER:
You don't mention how this row is to be selected? Do you with to pass this
value to the form when you open it? It is just not clear how/when/where you
want this row to be selected? To open a form to ONE record, you can simply
go:
docmd.OpenForm "frmCustomers",,,"id = 123"
The above would open he form, and then send the form to the above one
record. However, in your case, it seems we want to open the form, but that
form might have many records, and we just want to position the record to id.
Lets assume this, and use 123 for our example. We can go
docmd.OpenForm "my",,,,,,123
Note the number of commas...we are simply passing the value of 123 to the
form, and we can example this value passed.
So, now, in the forms on load event, we position the form to customer with
id = 123
me.RecordSet.FindFirst "id = " & me.OpenArgs
b) navigate via
The above is generally the default for a datasheet, but if you are using a
continues form, then you need to add the following code to the forms keydown
event handler, and set the forms keypreview = yes.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
' key hand
On Error Resume Next
Select Case KeyCode
Case vbKeyUp
KeyCode = 0
DoCmd.GoToRecord acActiveDataObject, , acPrevious
Case vbKeyDown
KeyCode = 0
DoCmd.GoToRecord acActiveDataObject, , acNext
End Select
End Sub
c) 'Copy & Paste' the row to another sub-datasheet on the same form via
another control on that form.
Copy and paste sounds like a bad word here, we you want to do is copy the
reocrd via a append query to the other table?
You can go:
dim strSql as string
strSql = "INSERT INTO tblSecondTable ( Description, Catagory, amount ) " & _
" SELECT Description, Catagory, amount FROM tblAnswers " & _
" where ID = " & me!id
CurrentDB.Execute
You also should do a requery on the 2nd form to show the above update...
me.MySubForm2.requery
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
***********************************************************************************
It's a bit missleeding now I have worked out how to enter my search criteria
into the query. Now I just want to know how to tab into the forms datasheet
with the entire row selected.
THANKS.
Marshall Barton said:
OK that helps a little, but I still don't understand what
you want in the way of highlighting records.
You have also intoduced a whole new concept when you mention
using a subdatasheet. As I said before, you can not control
the highlighting in a datasheet form, much less a
subdatasheet. If you are using that term in a casual way,
be aware that it is misleading and not communicating your
real requirements.
As for copying a record using code, that's fairly
straightforward, but you have to specify the details of how
that should happen. Which table should it be appended to?
Which fields should and should not be copied? What are the
names of the controls on the form and what fields (and their
type) are they bound to? For instance, if all the fields
(except an AutoNumber primary key?) in the table are to be
copied from the form's current record's visible controls to
the same table that the form is bound to, you can use the
button wizard to generate a simple minded record duplication
procedure. If all those presumptions are not met, then a
different procedure will be needed.
--
Marsh
MVP [MS Access]
Just to answer your points to clarify all this:
1. The refresh button simply updates the query match all records starting
with "xyz", the user then navigates to the record they want to select,
simply because there are lots of formats eg; music formats like cd, cda,
cd5, vynil, with the same artist & title, they also have different prices,
so batch records works best. Hope that helps.
2. I need to append all the fields for that record (row)eliminating user
error having to select all the fields. Highlighting the entire row in the
sub-datasheet as default, you can do this manually by selecting the arrow
next to the record but want it to be default when tabbing into the
sub-datasheet then simply user scrolls with cursor keys to the record that
fits & hits the append button.
postman wrote:
How to highlight an entire row of records and hold this format while
user
navigates to correct record, (6 fields) so an append query (via a
control)
can then be run to append the selected row to another table.
I have a product search form with:
1. An unbound text box (that is the criteria for a query) for user data
entry eg: Like ([forms]![Frm_FindTitles_DVD]![Input01]) & "*")
2. A control button 'refresh form data' that refreshes form data once
data
input complete.
3. a datasheet subform for the query.
When the form opens the curser is in the text box awaiting data entry,
the
user then refreshes form data and the records matching query criteria
are
shown in the datasheet.
So will need to have the row automatically selected once the form data
has
been refreshed (nice), or manually select the row by clicking on the
arrow
next to the record row (which highlights that entire row), then
navigating to the record with keyboard up/down keys to select the
required
row. I know how to build an append query based on a form controls etc.
so
have done that ok. I would guess that the "selected" record row are the
required data for the append query & nothing more needs to be done on
the
query.
MY QUESTION:
1. How to highlight an entire record row automatically, and hold this
format
while user navigates to correct record.
2. How to use the record row in an append query.
Would the code look like:
INSERT INTO [Tbl_SBuy Temp] ( Title, Format, SPrice, BCPrice, BTPrice )
SELECT Forms!Frm_FindTitles_BOOKS!TITLE AS Expr1,
Forms!Frm_FindTitles_BOOKS!FORMAT AS Expr2,
Forms!Frm_FindTitles_BOOKS!SPrice AS Expr3,
Forms!Frm_FindTitles_BOOKS!CBPrice AS Expr4,
Forms!Frm_FindTitles_BOOKS!TBPrice AS Expr5;
"Marshall Barton" wrote
It's easy enough to get the text box to select a record in a
subform (even if I don't understand what/why a "refresh" is
needed), but I don't think you can "highLight" a row in a
datasheet (sub)form. The current record is usually
indentified by reverse colors, but that will not "stick"
when you navigate to another record. I have no idea what
you mean by "correct record" or why you would want to
maintain a hightlight on an "incorrect" record???
It's a little complicated, but you could highlight two or
three different records with different colors by using a
continuous view (sub)form instead of datasheet view.