Search results

  1. G

    Dlookup resulting in null value

    If I put a breakpoint on that statement and run the code and hover the cursor over the " & Forms![frmBooking]![cboProductID]) part the following displays under teh cursor; Forms![frmBooking]![cboProductID]="482" which is what I expect. But when I hover the cursor over iProdType the value of 0...
  2. G

    Dlookup resulting in null value

    Thanks CJ I tried iProdType = DLookup("ProductTypeID", "tblProduct", "ProductID = " & Forms![frmBooking]![cboProductID]) because this code runs in a subform to frmBooking which is where cboProductID is located. I am now receiving the error 3075 Syntax error (missing operator) in query...
  3. G

    Dlookup resulting in null value

    I am trying to run this code but getting a run time error 94 - null value - when it shouldn't be. I am thinking I have written the Dlookup incorrectly? Private Sub txtProductName_Click() Dim iProdType As Integer Dim ProductID As Integer iProdType = DLookup("ProductTypeID", "tblProduct"...
  4. G

    Troubleshoot Dlookup

    I tried this immediately after it was suggested but it had no effect. I rationalised because the After_Update occurs on a field that has been inserted by the SQL.:banghead:
  5. G

    Troubleshoot Dlookup

    More troubleshooting. Into the watch window I have pasted; DLookup("ProductTypeID", "tblProduct", "ProductID = Forms![frmBooking]![cboProductID].[Value]") and in the Type column it is listed as Variant/Long. Forms![frmBooking]![cboProductID].[Value] is reported as a String in the type...
  6. G

    Troubleshoot Dlookup

    Here is teh statement now; iProdType = DLookup("ProductTypeID", "tblProduct", "ProductID = Forms![frmBooking]![cboProductID].[Value]") If I paste ?DLookup("ProductTypeID", "tblProduct", "ProductID = Forms![frmBooking]![cboProductID].[Value]") into the immediate window I get the result I am...
  7. G

    Troubleshoot Dlookup

    Adding the bracket corrected it but the statement still is not reporting a result.
  8. G

    Troubleshoot Dlookup

    Took your suggestion; iProdType = DLookup("ProductTypeID", "tblProduct", "ProductID = " & forms![frmBooking]![cboProductID] But the statement highlights in red - the syntax is not correct
  9. G

    Troubleshoot Dlookup

    On the main form is a combo box (cboProductID). The user selects an item in the combo box and an SQL Insert statement inserts the item into a subform of the main form. I am trying to determine the ProductTypeID of the item that has been inserted into the subform and am trying to use this...
  10. G

    DoCmd.OpenQuery...Property not found

    So here is the code; Option Compare Database Option Explicit Public gIntProdType As Integer Private Sub cmdInboundTransport_Click() Dim intProdType As Integer intProdType = 1 SetProdType (intProdType) DoCmd.OpenQuery "qryProductByType" End Sub Sub SetProdType(intProdType As...
  11. G

    DoCmd.OpenQuery...Property not found

    Thanks spikepl but if I delete that declaration I get an error saying gIntProdType hasn't been defined.
  12. G

    DoCmd.OpenQuery...Property not found

    I don't understand. At teh head of the code is the statement Public gIntProdType As Integer - therefore its value has been declared publicly. Why is it not available to the UDF?
  13. G

    DoCmd.OpenQuery...Property not found

    Right, so this is the problem, or at least one of the issues you alluded to. So therefore the value of gIntProdType will have to be stored publicly.
  14. G

    DoCmd.OpenQuery...Property not found

    Thanks, everything compiles. The value of of gIntProdType is successfully stored throughout the form code but when the query is called this value must be lost because the query returns an empty value ie the value of gIntProdType =0. Following the code, the value of gIntProdType is lost the...
  15. G

    DoCmd.OpenQuery...Property not found

    Okay. So I have; Public Function GetProdType() As Integer Dim gIntProdType As Integer GetProdType() = gIntProdType End Function But then I get a compile error; Function call on left side of assignment must return Variant or Object.
  16. G

    DoCmd.OpenQuery...Property not found

    So Insert->Module and then insert code; Option Compare Database Option Explicit Function GetProdType() Dim gIntProdType As Integer ' Return the value of the module variable. GetProdType() = gIntProdType End Function But this doesn't work. Bit of a beginner, can someone give me some...
  17. G

    DoCmd.OpenQuery...Property not found

    I have a button on a form which on clicking runs this code. Everything runs fine except the line; DoCmd.OpenQuery "qryProductByType". In this query is the criteria GetProdType(). The error message is Run time error 3270 Property not found. Is the problem with the Function GetProdType()...
  18. G

    Syntax error with INSERT statement and sub form

    Your solution did work. Can you please tell me what the "& and the ' do in an SQL statement.
  19. G

    Keeps asking for variable value previously declared

    At run time this code asks for iProductID despite the fact that this variable has been correctly declared. I know this because I have utilised the watch window for watching the value of iProductID right through to the end of the code. I have also used the intermediate window to determine its...
  20. G

    Subform naming - best practise

    Perhaps I wasn't clear. Is best practice to name the following way; Subform control; sbfNameX and the subform that sits in the subform control; fmNameX - or should it be sbfNameY
Back
Top Bottom