Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011
    Posts
    2

    Unanswered: Regarding the Date

    Dear All,

    I have 3 tables called Input, Daily Production, Preventive Maintenance.

    In INPUT TABLE FIELDS ARE MENTIONED BELOW:
    IP_PRTNUMBER - PART NUMBER,
    IP_PRTNAME - PART NAME,
    IP_CAVITY - CAVITY,
    IP_CYCTM - CYCLE TIME,
    IP_QTY - QUANTITY,
    IP_PLAN_DTFM - PLAN DATE FROM,
    IP_PLAN_DTTO - PLAN DATE TO,
    IP_PLAN_MNTH - PLAN MONTH,
    IP_MCNUM - MACHINE NUMBER

    Here I want to know if I entered the PLAN DATE FROM field I need to get PLAN DATE TO (date) automatically. So how to give the formula and where do I need to give that?

    The formula is mentioned below
    =((([IP_QTY]/(79200/[IP_CYCTM])*[IP_CAVITY]))+[IP_PLAN_DTFM])

    Please help me in this regard.

    Thanks in Advance

    Regards

    Lokesh Kamath

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    There is no computed fields in an Access table so you'll have to create/update the value of the field IP_PLAN_DTTO when the value of the related fields (IP_QTY, IP_CYCTM, IP_CAVITY, IP_PLAN_DTFM) changes. This is done on a form, using the AfterUpdate event of the controls bound to the different field. Ex:
    Code:
    Private Function Compute_IP_PLAN_DTTO()
    
        Me.IP_PLAN_DTTO.Value = (((Me.IP_QTY.Value / (79200 / Me.IP_CYCTM.Value) * Me.IP_CAVITY.Value)) + Me.IP_PLAN_DTFM.Value)
        
    End Function
    
    Private Sub IP_CAVITY_AfterUpdate()
    
        Compute_IP_PLAN_DTTO
        
    End Sub
    
    Private Sub IP_CYCTM_AfterUpdate()
    
        Compute_IP_PLAN_DTTO
        
    End Sub
    
    Private Sub IP_PLAN_DTFM_AfterUpdate()
    
        Compute_IP_PLAN_DTTO
        
    End Sub
    
    Private Sub IP_QTY_AfterUpdate()
    
        Compute_IP_PLAN_DTTO
        
    End Sub
    However storing a computed value into table is not recommended because it is not dynamic (nothing garantees that the computed field will be updated when the value of a related field changes) and sooner or later it causes data inconsistencies. The canonical solution consists in creating a query that selects the required columns and adds the computed one. So in your case:
    Code:
    SELECT IP_PRTNUMBER, IP_PRTNAME, IP_CAVITY, IP_CYCTM, IP_QTY, IP_PLAN_DTFM, ((([IP_QTY]/(79200/[IP_CYCTM])*[IP_CAVITY]))+[IP_PLAN_DTFM]) AS IP_PLAN_DTTO, IP_PLAN_MNTH, IP_MCNUM 
    FROM etc...
    How you can find a date as the result from that formula is one thing I cannot understand, though. You'll probably have to use a format or casting function to convert the resulting value to the proper data type.
    Have a nice day!

  3. #3
    Join Date
    May 2011
    Posts
    2

    Re: Regarding the Date

    Dear Sir,

    Thanks for your response.

    One more doubt I have i.e. In Forms I am got the answer. But same thing I need to get it VB. So how do I import that form in VB?

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If I understand your question correctly, you want to create in VB (or VB.Net) the same application as the one created in Access. Unfortunately there is no direct correspondence between forms and controls in Access and forms and controls in Visual BASIC. The main difference is that Access forms and controls are "data aware", i.e. they have properties that can bind them directly to a data source (RecordSet). In VB and VB.Net you need to use other solutions to create a data flow between a form and its controls and a data source. These solutions require additional objects and more code than with Access.

    To keep it short, the principles are the same but the techniques are slightly different. You'll probable receive more help in a forum dedicated to VB/VB.Net for questions concerning the use of these programming environments. See for instance: VBForums - Visual Basic and VB .NET Discussions and More!
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •