Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data-entry

Status
Not open for further replies.

rookery

Programmer
Apr 4, 2002
384
GB
Hi people

Another, probably quite trivial question, I'm afraid! I have a Main Form - "Customers" - which has an Add button on. When you click this another Form is called. This is the data-entry form. I am trying to work it so that once I OK the data-entry form, the record details that I have just entered is the one displayed in the main Form. I'm sure its somewhere along the lines of LastModified but I just cant seem to get it to work. This is the code that I've used so far:

Private Sub cmdUpdate_Click()

If MsgBox("Are you sure you want to add the record?", 4, "Update?") = 6 Then
Set dbs = CurrentDb
Set MyRS = dbs.OpenRecordset("Customers", dbOpenDynaset)

With MyRS
.AddNew
If Len(Trim(Text0)) > 0 Then
![Title] = UCase(Mid(Text0, 1, 1)) & Mid(Text0, 2)
End If
If Len(Trim(Text2)) > 0 Then
![Forename] = UCase(Mid(Text2, 1, 1)) & Mid(Text2,2)
End If

![TelWork] = [Text20]
![TelFax] = [Text22]
![TelMobile] = [Text24]
! = [Text26]

.Update
MyRS.Bookmark = MyRS.LastModified
Forms![customers].Bookmark = MyRS.Bookmark
End With

MsgBox "Record has been added!"
Me![Text0] = ""
Me![Text2] = ""
Me![Text20] = ""
Me![Text22] = ""
Me![Text24] = ""
Me![Text26] = ""
Me![Text0].SetFocus
dbs.Close

Else
Me![Text0].SetFocus
Exit Sub
End If
End Sub

Any help would be much appreciated....
 
Is there a reason for having an unbound form & using DAO for data-entry. Would it not be simpler to connect directly to the recordset by binding the data-entry form to it?

What is the primary key for your customers table. I would suggest closing (or hiding) the main form before data-entry, then re-opening the main form after data-entry & opening it with the newly entered record displayed. There are many ways of achieving this... James Goodman
 
Thanks James for your reply. A couple of points:

1) I found that by binding a form to the table whatever data-entry I entered was saved to the table even if I realised at the end that the details were wrong.

2) I wasn't keen to have the main form shut down whilst I did my data-entry. I want the user to be able to verify what they've just entered straight away, in case of any mistakes.

I have been able to solve the problem by using the GoToRecord command, which has worked a treat. I'm not sure if this is the most efficient of procedures but considering it works I'm not sure I care too much!! However many thanks for your reply as I'm sure I'll be on here many more times in the future. Is it always this hard to begin with...?
 
You can handle data verification on bound forms by using the Before_Update event.


However, if everything is working, then i wouldnt worry about it too much :)


James Goodman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top