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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding multiple records without having to enter repeating info 2

Status
Not open for further replies.

pdupreez

Technical User
May 16, 2001
49
ZW
I wish to create a data entry form, where the user will enter production data, per day. Fields are:

Date
PlantID
SourceID
TaskID
ProductID
PackingID
HoursPerm
HoursContr

The Date and PlantID will be common for a number of records, and I do not wish to reenter each time, so I want the user to enter a date and plantid (maybe in an inputbox?)
and then just enter the rest of the data, until a blank entry is made, where the user will be returned to select a new date, plantid unless a blank entry is made again.

I cannot seem to find a way to transfer data from an unbound textbox to a database field, other than for the first occurence when I open a form, using code in the form_load procedure. I looked at form_afterupdate, beforeupdate, textbox_after/before etc, and no joy?

Please help!

Thanks

Pieter
 
The way I've done this in the past is to create one form to put in the common information. Then I put command buttons on that form to open the other forms. In the properties of the input box on the second form, I'll set the default value of the input box equal to the value of the input box on the first form. This works as long as both forms are open.
 
Thanks JJOHNS

Appreciate the post, but it still produce additional keystrokes/entry per record, and all I want is a simple way of quickly entering a pile of data into a database, with a sort of a loop. In the old Dbase3 days, this was fairly simple, but I cannot seem to be able to reproduce the simplicity of the old Dbase input forms.

Regards

Pieter
 
In your Table, in Design Mode, you should be able to go to "Default Value" and you can type in a general pattern for that field; for example: EX-4000. If you know the beginning of each field will start with EX-4000 then you can type "EX-4000" in the "Default Value" and every new record you create will have "EX-4000" in that field.
 
I have the same problem with one of my forms. In my case I have the following:
TrainID (for date/time of training)
BusID (for the Business sending attendees)
FirstName
LastName (actual attendees)

I have more than one business sending more than one person to training sessions. I would like to be able to select a training id, then be able to select a business, input x number of names, then select the next business, input x number of names, THEN select a new training session and do the same. The idea would be to have to only input each training instance once and each business instance once. So far I haven't figured out how to do it. Unfortunately, my SQL knowledge is VERY limited... any suggestions?

Thanks!!!
 
I have accomplished this before by changing the DefaultValue Property of the text box that I want to remain unchanged to the last value that was entered into it. This can be done with an Event Procedure placed in the Form’s BeforeUpdate Event. The idea is to capture the current value of the text box as a variable and then pass that variable to the text box’s DefaultValue property. You must be very careful to avoid null values as the DefaultValue Property will not accept a null. Consider this code based on the last thread:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(TrainID) = True Then
Cancel = True
TrainID.SetFocus
Else
Dim myvariable1 As Date
Dim myvariable2 As Variant
myvariable1 = TrainID.Value
myvariable2 = "#"
TrainID.DefaultValue=myvariable2 & myvariable1 & myvariable2
End If

If IsNull(BusId) = True Then
Cancel = True
BusId.SetFocus
Else
Dim myvariable3 As String
Dim myvariable4 As Variant
myvariable3 = BusId.Value
myvariable4 = """"
BusId.DefaultValue=myvariable4 & myvariable3 & myvariable4
End If
End Sub

The validation could also be accomplished using the ValidationRule, but I prefer to use code as you can also include your own message etc.

Hope this helps.

Let me know if you need an explanation of any of the code elements.

Greg

goschutz@yahoo.com

 
Hi

Try this - credit to Ray White -
For every Text Box you want to Carry Foward to the new record put ( Carry ) in it's Tag Properties

Place this Code in your Forms AfterUpdate Event
*********************
Private Sub Form_AfterUpdate()
Dim ctl As Control
For Each ctl In Screen.ActiveForm.Controls
If ctl.Tag = "Carry" Then
ctl.DefaultValue = """" & ctl.Value & """"
End If
Next
End Sub
*********************

I have tried this in 97 and works fine.

tee.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top