Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub Command2_Click()
  2.     Unload Me
  3.     frmMain.Show
  4. End Sub
  5.  
  6. Private Sub Command3_Click()
  7.     'Routine to insert organisation
  8.    orgrecord.ID = Text1.Text
  9.     If Combo1.Text = "Sal." Then
  10.         orgrecord.Sal = ""
  11.     Else
  12.         orgrecord.Sal = Combo1.Text
  13.     End If
  14.     orgrecord.Forename = Trim(Text16.Text)
  15.     If Text2.Text = "Middle" Then
  16.         orgrecord.Middlename = ""
  17.     Else
  18.         orgrecord.Middlename = Trim(Text2.Text)
  19.     End If
  20.     orgrecord.Surname = Trim(Text3.Text)
  21.     If Combo2.Text = "Suffix" Then
  22.         orgrecord.Suffix = ""
  23.     Else
  24.         orgrecord.Suffix = Combo2.Text
  25.     End If
  26.     orgrecord.Email = Text4.Text
  27.    
  28.     'Phone saves
  29.    orgrecord.Phone1_Detail = Combo3.Text
  30.     orgrecord.Phone1_Number = Text5.Text
  31.     orgrecord.Phone2_Detail = Combo4.Text
  32.     orgrecord.Phone2_Number = Text6.Text
  33.  
  34.     'Address save
  35.    If Combo5.Text = "Home" Then
  36.         orgrecord.Primary_Address = Trim(Combo5.Text)
  37.         orgrecord.Hadd_Street = Text7.Text
  38.         orgrecord.Hadd_City = Text8.Text
  39.         orgrecord.Hadd_County = Text9.Text
  40.         orgrecord.Hadd_Country = Text10.Text
  41.         orgrecord.Hadd_Postcode = Text11.Text
  42.     ElseIf Combo5.Text = "Work" Then
  43.         orgrecord.Primary_Address = Trim(Combo5.Text)
  44.         orgrecord.Wadd_Street = Text7.Text
  45.         orgrecord.Wadd_City = Text8.Text
  46.         orgrecord.Wadd_County = Text9.Text
  47.         orgrecord.Wadd_Country = Text10.Text
  48.         orgrecord.Wadd_Postcode = Text11.Text
  49.     Else
  50.         orgrecord.Primary_Address = Trim(Combo5.Text)
  51.         orgrecord.Oadd_Street = Text7.Text
  52.         orgrecord.Oadd_City = Text8.Text
  53.         orgrecord.Oadd_County = Text9.Text
  54.         orgrecord.Oadd_Country = Text10.Text
  55.         orgrecord.Oadd_Postcode = Text11.Text
  56.     End If
  57.    
  58.     orgrecord.Category = Combo6.Text
  59.     orgrecord.Flagged = Check1.Value
  60.     orgrecord.Keyword1 = Label10.Caption
  61.        
  62.     Open App.Path & "\orgfile.rnd" For Random As #1 Len = Len(orgrecord)
  63.         Put #1, Text1.Text, orgrecord
  64.     Close #1
  65.    
  66.     Unload Me
  67.     frmMain.Show
  68. End Sub
  69.  
  70. Private Sub Form_Load()
  71.     'center the form
  72.    Me.Move (Screen.width - Me.width) / 2, (Screen.height - Me.height) / 2
  73.    
  74.     If SelectedFlag = 0 Then
  75.         'Call proc to retrieve list of users for combobox
  76.        'load the saved users' list
  77.        Open App.Path & "\userfile.rnd" For Random As #1 Len = Len(userrecord)
  78.             While Not EOF(1)
  79.                 Get #1, , userrecord
  80.                     If userrecord.userID > 999 Then
  81.                         'i = i + 1
  82.                        Combo7.AddItem userrecord.UserName
  83.                     End If
  84.             Wend
  85.         Close #1
  86.         Combo7.Text = Combo7.List(0)
  87.     End If
  88.  
  89.     'Check if coming in from a retrieve request
  90.    If SelectedFlag = 1 Then
  91.         'Routine to retrieve the record according to organisationID from main screen
  92.        Open App.Path & "\contactfile.rnd" For Random As #1 Len = Len(orgrecord)
  93.             Get #1, SelectedID, orgrecord
  94.         Close #1
  95.         'Routine to retrieve contact
  96.        Text1.Text = orgrecord.ID
  97.         Combo1.Text = orgrecord.Sal
  98.         Text16.Text = orgrecord.Forename
  99.         Text2.Text = orgrecord.Middlename
  100.         Text3.Text = orgrecord.Surname
  101.         Combo2.Text = orgrecord.Suffix
  102.         Text4.Text = orgrecord.Email
  103.        
  104.         Combo3.Text = orgrecord.Phone1_Detail
  105.         Text5.Text = orgrecord.Phone1_Number
  106.         Combo4.Text = orgrecord.Phone2_Detail
  107.         Text6.Text = orgrecord.Phone1_Number
  108.        
  109.         'Address
  110.        Combo5.Text = orgrecord.Primary_Address
  111.         If Combo5.Text = "Home" Then
  112.             Text7.Text = orgrecord.Hadd_Street
  113.             Text8.Text = orgrecord.Hadd_City
  114.             Text9.Text = orgrecord.Hadd_County
  115.             Text10.Text = orgrecord.Hadd_Country
  116.             Text11.Text = orgrecord.Hadd_Postcode
  117.         ElseIf Combo5.Text = "Work" Then
  118.             Text7.Text = orgrecord.Wadd_Street
  119.             Text8.Text = orgrecord.Wadd_City
  120.             Text9.Text = orgrecord.Wadd_County
  121.             Text10.Text = orgrecord.Wadd_Country
  122.             Text11.Text = orgrecord.Wadd_Postcode
  123.         Else
  124.             Text7.Text = orgrecord.Oadd_Street
  125.             Text8.Text = orgrecord.Oadd_City
  126.             Text9.Text = orgrecord.Oadd_County
  127.             Text10.Text = orgrecord.Oadd_Country
  128.             Text11.Text = orgrecord.Oadd_Postcode
  129.         End If
  130.        
  131.         Combo6.Text = orgrecord.Category
  132.         If orgrecord.Flagged = True Then
  133.             Check1.Value = True
  134.         Else
  135.             Check1.Value = False
  136.         End If
  137.         Label10.Caption = orgrecord.Keyword1
  138.     Else
  139.         'Routine to generate OrganisationID
  140.        ID = 1000
  141.        
  142.         Open App.Path & "\orgfile.rnd" For Random As #1 Len = Len(orgrecord)
  143.             While Not EOF(1)
  144.                 Get #1, ID, orgrecord
  145.                     If orgrecord.ID = 0 Then
  146.                         Text1.Text = ID
  147.                         Close #1
  148.                         Exit Sub
  149.                     Else
  150.                         ID = ID + 1
  151.                     End If
  152.             Wend
  153.         Close #1
  154.     End If
  155. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement