When select value from combo, highlight that record in Access subform datasheet - forms

I have an Access form with a combobox and a subform on it. The subform is in datasheet mode (the way I want it). What I'm trying to do is make a sort of search function. When something is selected from the combobox, I want the subform's datasheet to scroll to and highlight the matching record.
I do not want to filter the subform (i.e. remove all non-matching records).
Can anyone give me some guidance on how to achieve this?

Something like this:
Private Sub Combo0_AfterUpdate():
With Me.Child0.Form.Recordset
.FindFirst "ID_Field=" & Me.Combo0
End With
End Sub

Related

Take value from field in Form to a new record in other Table

Would really like some guidance on this one. Not as easy as the title might say at first and I'm stuck beyond all and frustrated.
So:
I have a MainForm (With a current ID I would like to stay on!)
I have a Subform (search engine that searches in various linked excel files)
I have 2 tables; one for the Mainform, and one for Items
So on the Mainform, I display the Subform (search).
I do my search and find a specific item in the excel files
I have a command button, that I want to click save the found item in the search field, into my ItemsTable as a new record.
Currently I'm doing this:
Private Sub Command13_Click()
Forms!MainForm.Form.Item1.Value = Me.Searchresult.Value
End Sub
This does actually post my search result into a new field and saves it into the itemsTable.
My problem: I don't need to actually have a field to post to. I just want it to write directly to my table and store it there as a NEW record. (Right now it just overwrites the previous data. Logically because its the same field every time with the same properties).
Can someone PLEASE help me with this one?
Options:
set focus to the subform container then move to New Record row followed by your code, this is not simple, review https://access-programmers.co.uk/forums/showthread.php?t=127337
use SQL INSERT action then requery the subform
CurrentDb.Execute("INSERT INTO Items(Item1) VALUES('" & Me.Searchresult & "'")

Ms Access, double click listbox element to update form

I'm trying to make an improved search text field in a form in Access. I'm searching through my customer names and I've been able to implement a "search as you type" textbox linked to a listbox where the matching records show up.
Now I want to simply double click on an item in the listbox and have all the fields of the form update automatically. I am pretty sure it already exists, but I havn't been able to find it. I'd be glad to be pointed to an existing resource or anything.
Thanks for your help!
In the listbox's On Dbl Click event, click the button and choose code builder.
Then you will need to write some code to figure out which row of the listbox is selected. Use the .ItemData method of your listbox. See here
This will return the value in the bound column of your listbox, which you can use to tell the form to navigate to the record that matches that bound column value. You may want to use a DLOOKUP to find the Record ID if the listbox bound column is not the primary key. Then you navigate to the record. For that you will likely need the .FindRecord method. See here

Open form to record seleced from double click on same record in datasheet form

I've got a pair of forms that are both based on the same data table. One is a single form with a better layout of all the onfo, the other is a datasheet. I want to be able to double click on the project number in the datasheet form to open the details single form to that same record.
I've done it on a simplified practice db, but when I try it in my current db it opens the second form, but to a new record entry. This form is one that was a template that someone else downloaded and modified for our purpose, so maybe there is something stored somewhere else that is interrupting the filtering.
I deleted a couple of macros that I thought might be interfering, made sure that the form properties are cycling all records and that on form load it isn't directed to a new record. I can't figure out where else there is something preventing the form from being filtered for the selected record. Here's the code I've used in the datasheet form:
Private Sub combined_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmTaskDetailsExisting", acNormal, , "SLRtaskID = " & Me.SLRtaskID
End Sub
Anyone have an idea what I'm missing here.
Have you considered doing this with a split Form? You will have the Detailed view per record and the dataseet.
If you really want two independent forms due to your needs, your code looks ok. But two things may be happening:
The value in Me.SLRtaskID is not correct. Put a breakpoint in the code and check it.
There is code in frmTaskDetailsExisting that moves it to a new record when it is opened, regardless to the filter.

MS Access - Advancing through record groups

I have a form with a subform. The record source for the subform is as follows:
SELECT [firstID], [secondID], [AAA], [BBB], [CCC], [DDD]
FROM Table1
WHERE firstID = [Forms].[frm1].[txtfirstID];
The subform groups the records together on the basis of txtfirstID but when I advance through the record selector it goes through every record, as expected. I would like to know if there is a way to click through the groups rather than each record within each group. I'm open to any way of doing it. Perhaps filtering through VBA??
Thanks!
First, add a combo box to your form. Set the RecordSource for the combo box to a distinct list of groups, or, if you have a group lookup table, select * from tblGroups. Set the display field to be group name, and the value field to be group id.
Second, after an item is selected from the combo box, modify the RecordSource sql of the form (your query) so that it uses the current value of the combo box. The value of the combobox would be what your where clause should be looking for.
I think you can do two ways to solve this:
1.- If you related main form to subform by a field. In this case TxtFirstID of Main to FirstID of subform. It do all work when change main form and filter automatically on subform
2.- You can do and event OnChange form TxtFirstID on main form.
Sub TxtFirstID_Change()
Me.subfrmName.Form.RecordSource = "Select * from table1 where firstID=" & Me.TxtFirstID 'change the record source for the SubForm
me.subfrmName.Form.Requery 'Force Access to refresh the Record Source
end sub

Access comboxbox selection needs to change value in label control

On a form, I have a combobox, with the RowSource coming from a query (specifically, a calculated field in the query). When the user makes a selection, I want to update a label on the same form with a different column from that same query, but of course associated to the selection.
I'm fine with VBA and writing queries and whatnot, but I am not very familiar with Access forms.
By the way, I tried searching for an answer to this, but it was quite difficult because I don't know what this thing is really called that I am trying to do. A good link to a site explaining this would be perfectly fine (no need to write a bunch of stuff here if it already exists elsewhere).
In the After Update event of my combo box, cboUserID, I can set a label control, lblFoo, to the value of the second column in the selected row of the combo.
Me.lblFoo.Caption = Me.cboUserID.Column(1)
If your combo box is bound to a field in the form's record source, you may want to do that same operation from the form's On Current event also.
You can use the column property to refer to anything other than the bound column of a combo.
Rowsource: SELECT ID, SName, FName FROM Table
Me.MyCombo.Column(2)
This would return FName.
-- http://msdn.microsoft.com/en-us/library/aa224084(v=office.11).aspx
Me.MyLabel.Caption = Me.MyCombo.Column(2)