If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
SQL behind a form's control
I have a textbox control (PO) on a form (frmInvoice) which I would like to
populate with the result of a query. SELECT TblInvoice.[Purchase Order] FROM TblInvoice WHERE (TblInvoice.InvoiceID)= (SELECT Max(InvoiceID) FROM TblInvoice WHERE([TblInvoice].[Company_ID]=[Forms]![FrmInvoice]![Company_ID])); I would like to associate the result of querry above with the On Enter event of the control (PO) so that the querry's result will become the control's default value. Can somebody help with the VBA syntax? |
#2
|
|||
|
|||
SQL behind a form's control
Why not just use the DMax function instead? Put it in the form's On Current
event. Me.(PO).DefaultValue = nz(Dmax("InvoiceID","TblInvoice","[TblInvoice].[CompanyID =" & Me.CompanyID),0) Brian "Rafi" wrote in message ... I have a textbox control (PO) on a form (frmInvoice) which I would like to populate with the result of a query. SELECT TblInvoice.[Purchase Order] FROM TblInvoice WHERE (TblInvoice.InvoiceID)= (SELECT Max(InvoiceID) FROM TblInvoice WHERE([TblInvoice].[Company_ID]=[Forms]![FrmInvoice]![Company_ID])); I would like to associate the result of querry above with the On Enter event of the control (PO) so that the querry's result will become the control's default value. Can somebody help with the VBA syntax? |
#3
|
|||
|
|||
SQL behind a form's control
Or if you prefer,
Dim db As Dao.Database Dim rs as Dao.Recordset Set db = CurrentDb Set rs = db.OpenRecordset("SELECT TblInvoice.[Purchase Order] ..... Me.PO.DefaultValue = rs!InvoiceID rs.Close db.Close set db = Nothing Brian "Brian Bastl" wrote in message ... Why not just use the DMax function instead? Put it in the form's On Current event. Me.(PO).DefaultValue = nz(Dmax("InvoiceID","TblInvoice","[TblInvoice].[CompanyID =" & Me.CompanyID),0) Brian "Rafi" wrote in message ... I have a textbox control (PO) on a form (frmInvoice) which I would like to populate with the result of a query. SELECT TblInvoice.[Purchase Order] FROM TblInvoice WHERE (TblInvoice.InvoiceID)= (SELECT Max(InvoiceID) FROM TblInvoice WHERE([TblInvoice].[Company_ID]=[Forms]![FrmInvoice]![Company_ID])); I would like to associate the result of querry above with the On Enter event of the control (PO) so that the querry's result will become the control's default value. Can somebody help with the VBA syntax? |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
What Are The Issues With MS Access Client to SQL Server DB | Smithers | General Discussion | 13 | January 9th, 2006 03:14 PM |
combo box, control source, and sql statements | anonymous | Using Forms | 1 | October 18th, 2005 05:48 PM |
Unable to insert record to Access via SQL from an ASP page | Norman Yuan | General Discussion | 1 | February 2nd, 2005 08:23 PM |
Forms Toolbar vs. Control Toolbox vs. Data Validation for drop dow | Scott | General Discussion | 1 | February 1st, 2005 01:51 PM |
Access Calendar | lost | General Discussion | 2 | July 7th, 2004 04:58 AM |