By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,863 Members | 838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,863 IT Pros & Developers. It's quick & easy.

Creating New Record From Sub Form

P: 2
Hi all.
Your have to forgive me knowledge, been a long time writing VB
I have had to create a new contacts directory for a specific use.
One part is to have an external contact section.
Very simply user clicks a button to add a new user, new form loads with basic required fields.
When entered and click save it should save new record to table and appear on the main form in a list. However it appears it is not creating a new URN ID.
Code below:

From Parent form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub New_Click()
  2.     DoCmd.OpenForm "External_Contact_New"
  3. End Sub
When completed fields click save
Expand|Select|Wrap|Line Numbers
  1. Private Sub Save_Click()
  2. Dim buff As String
  3.  
  4. On Error Resume Next
  5.     DoCmd.GoToRecord acDataForm, "External_Contact_New", acNewRec
  6.     If (MacroError <> 0) Then
  7.         Beep
  8.         MsgBox MacroError.Description, vbOKOnly, ""
  9.         DoCmd.Close acDataForm, "Form_Staff_Member_New"
  10.         Exit Sub
  11.     End If
  12.  
  13.     'moving data from buffer
  14.     buff_drop
  15.     'save data
  16.     DoCmd.Save
  17.     Me.Refresh
  18.     Me.Requery
  19. On Error Resume Next
  20.     Form_External_Contacts.Requery
  21.     buff = Form_External_Contacts.RecordSource
  22.     Form_External_Contacts.RecordSource = buff
  23.  
  24.     'DoCmd.Close acForm, "External_Contact_New"
  25.  
  26. End Sub
Buff_Drop Details
Expand|Select|Wrap|Line Numbers
  1. Private Sub buff_drop()
  2.     Full_Name.Value = B_Full_Name.Value
  3.     First_Name.Value = B_First_Name.Value
  4.     Surname.Value = B_Surname.Value
  5.     Profile.Value = B_Profile.Value
  6.     Company.Value = B_Company.Value
  7.     Office_Tel.Value = B_Office_Tel.Value
  8.     Mobile_Work.Value = B_Mobile_work.Value
  9.     Mobile_Personal.Value = B_Mobile_personal.Value
  10.     Out_1.Value = B_Out_1.Value
  11.     Out_2.Value = B_Out_2.Value
  12.     Email.Value = B_Email.Value
  13.     Notes.Value = B_Notes.Value
  14. End Sub
Any Help would be appreciated, thank you in advance.

If it will help i am happy to send over a blank data base and program.

Thank you

Andrew
Aug 4 '17 #1
Share this Question
Share on Google+
1 Reply


P: 2
RESOLVED
I figured it out, it was the fact the table didn't have an autonumber for the ID
No idea how or why it had changed but its now working..
Had to change other bits of code but all sorted.

Thankyou
Aug 4 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.