Results 1 to 6 of 6
  1. #1
    danbo is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    55

    Talking IIF I can't figure this out THEN I'm gonna toss my computer.

    Im using this database to keep track of customer information. The form that the following is based on is a change order form. If a customer disconnects his/her phone service the user clicks on a button that populates a new form with the following data.
    Our disconnected customers are issed a phone number with a suffix of 9000. Like 898-9001, 9002 etc.
    I would like the form to populate the correct field on the new form depending on whether this is a disconnected phone going back into service or not. Below is an example of what I have followed by what I would like to have. Any ideas without changing the whole thing would be greatly appreciated.
    Thanks!

    Private Sub Duplicate_Enter()
    DoCmd.OpenForm "Change Order", acNormal, , , acFormAdd
    Forms![Change Order].CRV = Forms![call history data]!NavigationSubform.Form!CRV
    Forms![Change Order].[Cable Pair] = Forms![call history data]!NavigationSubform.Form![Cable Pair]
    Forms![Change Order].Street = Forms![call history data]!NavigationSubform.Form!Street
    Forms![Change Order].[Phy Adrs] = Forms![call history data]!NavigationSubform.Form![Phy Adrs]
    Forms![Change Order].Notes = Forms![call history data]!NavigationSubform.Form!Notes
    Forms![Change Order].RST = Forms![call history data]!NavigationSubform.Form!RST
    Forms![Change Order].[Previous No] = Forms![call history data]!NavigationSubform.Form![Home Phone]
    Forms![Change Order].[Lot No] = Forms![call history data]!NavigationSubform.Form![Lot No]
    Forms![Change Order].[First Name] = "Quick"
    Forms![Change Order].[Last Name] = "Dial Tone"

    End Sub

    What I need it to create an IF THEN type statement that will allow the previous number to go to a specific location depending on the number.

    Example:
    If Forms![call history data]!NavigationSubform.Form![Home Phone] is > or =“898-8999” then Forms![Change Order].[Previous No] = Forms![call history data]!NavigationSubform.Form![Home Phone]
    Else


    Forms![Change Order].[Previous 9000] = Forms![call history data]!NavigationSubform.Form![Home Phone]

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    The correct syntax for > or = operation is: >=
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    danbo is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    55
    Quote Originally Posted by June7 View Post
    The correct syntax for > or = operation is: >=
    Ive never written code before and havent found much help online. could you review this and let me know if this is looking right?

    Option Compare Database
    Private Sub Duplicate_Click()
    DoCmd.OpenForm "Customer Details", acNormal, , , acFormAdd
    Forms![Customer Details].CRV = Forms![call history data]!NavigationSubform.Form!CRV
    Forms![Customer Details].[Cable Pair] = Forms![call history data]!NavigationSubform.Form![Cable Pair]
    Forms![Customer Details].Street = Forms![call history data]!NavigationSubform.Form!Street
    Forms![Customer Details].[Phy Adrs] = Forms![call history data]!NavigationSubform.Form![Phy Adrs]
    Forms![Customer Details].Notes = Forms![call history data]!NavigationSubform.Form!Notes
    Forms![Customer Details].RST = Forms![call history data]!NavigationSubform.Form!RST

    'works fine up to this point. the If Then Else isn't working at all.

    If Forms![call history data]!NavigationSubform.Form![Home Phone] <= "585-8999" Then
    Forms![Change Order].[Previous No] = Forms![call history data]!NavigationSubform.Form![Home Phone]
    Else: Forms![Change Order].[txtdisc] = Forms![call history data]!NavigationSubform.Form![Home Phone]
    End If

    End Sub

  4. #4
    danbo is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    55
    Quote Originally Posted by June7 View Post
    The correct syntax for > or = operation is: >=

    Actually Never mind. I just solved the problem. I needed your input as well but the other thing I was having issue with was I had txtdisc which was the disconnect date instead of txtterm which was the termination number. Thanks again!!!

  5. #5
    danbo is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    55

    Unhappy

    Quote Originally Posted by June7 View Post
    The correct syntax for > or = operation is: >=
    I have another question about the if then situation. The following is working like a champ but not doing everything I need it to do. I would like to add to the if, then, eles for the following:

    If Forms![call history data]!NavigationSubform.Form![Home Phone] <= "585-8999" Then
    Forms![Change Order].[Previous No] = Forms![call history data]!NavigationSubform.Form![Home Phone]
    AND Forms![Change Order].[Txtprev] = Forms![call history data]!NavigationSubform.Form![Prev9000]
    Else: Forms![Change Order].[Txtprev] = Forms![call history data]!NavigationSubform.Form![Home Phone]
    End If
    this is getting too complex for my little mind on Christmas vacation. Don't really need an answer... just venting. But if someone has one it would be great. for some reason it keeps looping on me when I try this


    Private Sub Duplicate_Enter()
    DoCmd.OpenForm "Change Order", acNormal, , , acFormAdd
    Forms![Change Order].CRV = Forms![call history data]!NavigationSubform.Form!CRV
    Forms![Change Order].[Cable Pair] = Forms![call history data]!NavigationSubform.Form![Cable Pair]
    Forms![Change Order].Street = Forms![call history data]!NavigationSubform.Form!Street
    Forms![Change Order].[Phy Adrs] = Forms![call history data]!NavigationSubform.Form![Phy Adrs]
    Forms![Change Order].Notes = Forms![call history data]!NavigationSubform.Form!Notes
    Forms![Change Order].RST = Forms![call history data]!NavigationSubform.Form!RST
    Forms![Change Order].[Lot No] = Forms![call history data]!NavigationSubform.Form![Lot No]
    Forms![Change Order].[First Name] = "Quick"
    Forms![Change Order].[Last Name] = "Dial Tone"
    Forms![Change Order].[Previous No] = Forms![call history data]!NavigationSubform.Form![Home Phone]
    If Forms![call history data]!NavigationSubform.Form![Home Phone] <= "585-8999" Then
    Forms![Change Order].[Previous No] = Forms![call history data]!NavigationSubform.Form![Home Phone]
    Else: Forms![Change Order].[Txtprev] = Forms![call history data]!NavigationSubform.Form![Home Phone]
    End If

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Not sure what you mean by 'looping'. Have you step debugged?

    When I use Else I always put the action on separate line. Don't know if that will make a difference. I don't think the closing End If is needed with one liner.

    If THIS then
    'do something
    Else
    'do something
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Cant Figure This Out
    By tabbycat1234 in forum Forms
    Replies: 12
    Last Post: 07-27-2011, 02:19 AM
  2. can't figure out what i'm doing wrong
    By m0use in forum Queries
    Replies: 4
    Last Post: 06-16-2011, 09:18 AM
  3. Need a query to figure all possible combinations
    By julestrip in forum Queries
    Replies: 1
    Last Post: 05-27-2011, 07:23 AM
  4. Cannot Figure this query out
    By ryan1313 in forum Queries
    Replies: 6
    Last Post: 08-13-2010, 12:54 PM
  5. Can't Figure It Out!!
    By jdohio5 in forum Database Design
    Replies: 1
    Last Post: 05-04-2006, 06:49 AM

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