Results 1 to 3 of 3
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Control to VBA code

    Code:
    IsComp: DLookUp("Action_Complete","[Change Request]","CR_No = " & [CR_No] & " AND Sub_No<>0")
    
    SDate: DLookUp("[Date_Closed]","[Change Request]","CR_No= " & [CR_No] & " AND Sub_No=0")
    
    Same: DLookUp("[Status 1]","[Switching]","CR_No = " & [CR_No])
    Question 1: Is there a way to combine the first 2 lines of "Control" code? Would this speed up the database?



    Question 2. Would it be quicker for the database to do this in VBA?

  2. #2
    InsuranceGuy is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Colorado
    Posts
    126
    1. You are returning different values with different logic. If you want to combine them into a single text box, just concatenate your outputs using the ampersand operator.
    2. Domain functions (D*) are notoriously slow. Using Recordset searches in VBA can be faster, but it's fairly complex. Given the nature of your questions, I wouldn't recommend taking that on until you get more experience under your belt.

    Jeff

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Its not to combine into a single text box.

    I use these to compare a status to determine the output with:

    Code:
    CR_Numberz: IIf([SUB_No]=0,Format([Change Request].[CR_No],"#"),Format([Sub_No]*0.01,"    " & " .00"))
    CR_Numberz1: IIf(([IsComp] And [Action_Complete]=False) Or [Same]<>[Final_Vote] Or ([Sdate]<>[Date_Closed]),IIf([CR_No] & Trim([CR_Numberz])=[CR_No] & [CR_No],[CR_No],[CR_No] & Trim([CR_Numberz])),[CR_Numberz])
    CR_Numbers: IIf([IsComp]=-1 And [Same]=[Final_Vote],[CR_Numberz],[CR_Numberz1])
    Where CR_Numbers is the final output. I couldn't see where you the need if all the CR_Numbers have an action_complete and the vote is all the same to be a different format.

    Previously it would look like

    159
    .01
    159.02 (Different Date where Action_Complete=True) but the final vote ended up the same as the rest.
    .03

    now I get

    159
    .01
    .02
    .03

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 09-09-2014, 01:07 AM
  2. Replies: 6
    Last Post: 06-11-2014, 01:00 AM
  3. code to apply control formatting
    By tariq1 in forum Programming
    Replies: 3
    Last Post: 07-21-2012, 12:36 PM
  4. Code not working with tab control
    By pg13Reader in forum Programming
    Replies: 4
    Last Post: 12-13-2011, 06:30 PM
  5. Tabular Control Code
    By benthamq in forum Programming
    Replies: 6
    Last Post: 09-12-2011, 04:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums