Query help

Damo10

Active Member
Joined
Dec 13, 2010
Messages
460
Hi,

I have a form that uses the date, name and department from another form as the default values, I have created a query that looks at these and gives the max value of how many enteries have been made for that person for the specidied date.

Can i run this query and have the number from the "max of Enteries" field as the deafult value for a textbox?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Strange that if your control is a combobox you can have a query as its source. I was just looking a few days ago at comboboxes - wouldn't it be great if you could display them without a scroll bar (so you have a combobox that looks like a textbox and can have a datasource?). A listbox of the right size might even do ... Hmm! Anyone ever try this?

As far as you're question goes, you can populate the texbox from behind your form with a query result:

Code:
Dim rs As DAO.Recordset
set rs = CurrentDB.OpenRecordset("Select Max(Field1) As MaxOfField1 From Table1")
If Not rs.EOF Then
    TextBox1.Value = rs.Fields(0).Value
End If
Set rs = Nothing

This could be in an open event for the form, or triggered by some other appropriate event.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top