Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Populate a field (97)

    I have a field on a form that when populated another field (which is a yes/no field) is checked. Here is the code I am using:

    Private Sub mthcode_BeforeUpdate(Cancel As Integer)
    If Me![mthcode].Value = Null Then
    Me![Reissueyn] = False
    Else
    Me![Reissueyn] = True
    End If
    End Sub

    It works fine when you manually populate the field and hit tab - the y/n field is populated. The problem is that the data that is going to populate the mthcode field is going to be imported from an Excel spreadsheet. I tested it and when the data is imported in, the y/n field does not populate. What event should I use or isn't this possible?

    Thanks for any help.

  2. #2
    Star Lounger
    Join Date
    Feb 2001
    Location
    Vancouver, BC, Br. Columbia, Canada
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate a field (97)

    I think you're going to have to create an update query to run after you append the data from Excel.
    Gwenda

  3. #3
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Populate a field (97)

    Hi Linda,
    In this case, the BeforeUpdate event is not occurring, as the data isn't changing. When you import from an Excel workbook, the data is already established, so you want to create an update query to set the Reissueyn field to True of False based on the content brought in with the Excel workbook.
    Wendell

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Populate a field (97)

    You could use the BeforeUpdate event of the form to set the Reissueyn field.

    Also the test:
    If Me![mthcode].Value = Null Then

    should be changed to:
    If IsNull(Me![mthcode]) Then

    BTW, where do you import the field from the Excel sheet? Is this already in the Access table at the time of data entry of the form?

    HTH
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

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