Access keeps adding a blank record on subform

Mark Liddle

Registered User.
Local time
Today, 01:46
Joined
Sep 12, 2000
Messages
13
In trying to learn how access (And VBA) works, I am writting a "contact management" application whereby users need to make telephonic contact with someone and then record what was discussed.
The parent form contains data about the contact. The subform records the "DATE" and the topic of what was "Discussed".

Whenever the user types data into the "Discussed" field the system appends a blank record (after the current one).
The net result is that I get 2 records for every call.

I rather want to set the focus back to the "Contact Code" on the parent form so that the user can select another contact and then record that call.

Thanks
 
I have had a similar problem.
The way round it I found is:
1.Set your data entry to NO
2.Set Allow Edits to YES
3.On the 'add new button' use DAO to programmatically add a new record to the data source(you may have to create an invisible field to get this to work) then requery the form.

The outcome is that on screen it looks like a new blank record has been added but really what you are doing is editing the record you've just created.

If anyone knows an easier way to stop an annoying blank record at the end of a data entry form I'd love to know how they've done it.

Formatian
 
Set your cycle control in the subform properties to current record only. By using your tab, you are selecting another record to be entered.

Good luck
 
Many thanks for the suggestions.
Have tried both methods that you have suggested and still am having no luck. (As you can see, I have taken a few days to get back to the forum.)
I think that Fornations idea has set me on the right course, but I obviously do not know enough about VBA to get it right.

I have created two extra fields on the parent form.
Called "Today" which defaults to todays date and "Remarks" which records what was discussed.

In the Remarks_AfterupDate() event, I am assigning the values of the Today and Remarks fields into variables called MyDate and MyString.
I then shift the focus to the subform
I dont know how to get the code to append a blank record (Or move the last records which is in effect blank (Other than the date which defaults to the current date) .... and then
fill in the MyDate and MyString values into the "Date" and "Discussed" field respectively. (These two fields are on my Subform called "CallSubform")

The following is the code that i have tried.

Private Sub Remarks_AfterUpdate()
Dim MyDate As Date
Dim MyString As String

MyDate = Me.Today
MyString = Me.Remarks
Me.CallsSubform.SetFocus

'Have tried both of the following lines, but doesnt seem to be working.
AddNew
'GoTo EOF

Me.Date = MyDate
Me.Discussed = MyString
Forms!Parent().SetFocus
Me.Remarks = ""
Me.MyAccNo.SetFocus

End Sub


The other thing that i have not been able to do is to step through the code (using Debug) - I keeps going to other events that I cannot seem to find when looking at the varioous fields properties.
Any suggestions ?
Thanks
 

Users who are viewing this thread

Back
Top Bottom