Creating New Record From Sub Form

AJB2510

New member
Local time
Today, 03:50
Joined
Aug 4, 2017
Messages
2
Hi all.
Your have to forgive me knowledge, has been a long time since 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 does not show in the table.

But this does work for internal contacts - do figured perhaps a database table property issue, but cant see obvious problem, or perhaps code? But basically same for both functions.. I am stuck...

Code below:

From Parent form:
Code:
Private Sub New_Click()
DoCmd.OpenForm "External_Contact_New"
End Sub[CODE]

When completed fields click save
[CODE]Private Sub Save_Click()
Dim buff As String

On Error Resume Next
DoCmd.GoToRecord acDataForm, "External_Contact_New", acNewRec
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
DoCmd.Close acDataForm, "Form_Staff_Member_New"
Exit Sub
End If[CODE]

'moving data from buffer
[CODE]buff_drop
'save data
DoCmd.Save
Me.Refresh
Me.Requery
On Error Resume Next
Form_External_Contacts.Requery
buff = Form_External_Contacts.RecordSource
Form_External_Contacts.RecordSource = buff

'DoCmd.Close acForm, "External_Contact_New"

End Sub[CODE]

[CODE]Buff_Drop Details
Private Sub buff_drop()
Full_Name.Value = B_Full_Name.Value
First_Name.Value = B_First_Name.Value
Surname.Value = B_Surname.Value
Profile.Value = B_Profile.Value
Company.Value = B_Company.Value
Office_Tel.Value = B_Office_Tel.Value
Mobile_Work.Value = B_Mobile_work.Value
Mobile_Personal.Value = B_Mobile_personal.Value
Out_1.Value = B_Out_1.Value
Out_2.Value = B_Out_2.Value
Email.Value = B_Email.Value
Notes.Value = B_Notes.Value
End Sub[CODE]

Any Help would be appreciated, thank you in advance.

I have attached the zip containing files.

Thank you

Andrew
 

Attachments

Last edited:
Hi all
So others will know my problem, i have managed to fix it.
Basically the ID for External Contacts Table was not set to AutoNumber.
No idea why this happened or when, soon as changed to Auto Number i got it working.
Had to change code slightly as noticed other mistakes i had done but after 3 days of trying to figure it out, i went to lunch came back and thought lets look at the table and bang, there was my problem.

:)
 

Attachments

Users who are viewing this thread

Back
Top Bottom