Good morning everyone:
I created a form and set the default view as a continuous form. Basically the form is displaying records in which the user can add or edit new ones. The record source for this form is a query that I built that is based on a table.
I have been working on this for several weeks and now I have been told that many times when a user wants to create a new record, much of the information that is displayed in a preexisting record is the same. Therefore, instead of rekeying in the same information (only making changes on a couple of the fields) they would like to copy the preexisting row and paste it into the “new” record row that is being displayed (the last row that is displayed) much like one would do in Excel.
Currently I have a before update event for writing new records:
[code=vb]
Private Sub Form_BeforeUpda te(Cancel As Integer)
'When a user is creating a new record the following code inserts the MonthID, YearID and
'The LocationsID. It does a Dlookup for the Locations ID when the control cboLocation is
'blank.
Dim frm As Form
Set frm = Forms!Forecast
If IsNull(frm![Binding_Percent age]) Then
MsgBox ("You need to select a Binding Percentage before you create a new record")
Cancel = True
Else: Cancel = False
End If
If Me.NewRecord Then
'If cboLocation is Not Null, grab the value from there
If Not IsNull(frm![cboLocation]) Then
JtnLocationsID = frm!cboLocation
YearID = frm!CboYear
MonthID = frm!CboMonth
Else 'Forms!Forecast ![cboLocation] is Null
'Check and see if all 3 Controls have values in them
If Not IsNull(frm![cboDivision]) And Not IsNull(frm![cboWrkReg]) And _
Not IsNull(frm![cboCreditReg]) Then 'values in all 3 Controls
JtnLocationsID = DLookup("[JtnLocationsID]", "tblLocationsMM ", "[DivisionIDFK] =" & frm![cboDivision] & _
" And [WrkRegIDFK] =" & frm![cboWrkReg] & " And [CreditRegIDFK] =" & _
frm![cboCreditReg])
YearID = frm!CboYear
MonthID = frm!CboMonth
Else
'no value in [cboLocation], and 1 or more values are missing in [cboDivision],
'[cboWrkReg], or [cboCreditReg]
MsgBox "1 or more values are missing in"
End If
End If
End If
End Sub
[/code]
I played around and discovered that I could, using the mouse, right click in one of the rows and select “copy” and then right click in the last row (the new record line) and select “paste”. Actually this was pointed out to me by one of the people I am working with. What happens though, is that the paste action does not take and it creates a “blank” record of which I can then right click in that row (the newly created “blank” one) and paste again the info. Then it works. I say “blank” because it actually did create a record on my table with the YearID, MonthID, & JtnLocationsID via the above mentioned code. These are fields that are not in the displayed rows, hence why I created the code to write new records to the table.
Given the copy and paste mindset of my end user what would be the best approach to easily satisfy their desire to not have to rekey much of the information that is already in previously displayed rows? I am relatively new at this so don’t know what the best solution. One thing to mentioned is that this particular table does not have any fields where duplicates are not allowed. I guess that is one less issue to deal with.
Does anybody have ideas on how they would approach this?
Thanks,
Keith :-)
I created a form and set the default view as a continuous form. Basically the form is displaying records in which the user can add or edit new ones. The record source for this form is a query that I built that is based on a table.
I have been working on this for several weeks and now I have been told that many times when a user wants to create a new record, much of the information that is displayed in a preexisting record is the same. Therefore, instead of rekeying in the same information (only making changes on a couple of the fields) they would like to copy the preexisting row and paste it into the “new” record row that is being displayed (the last row that is displayed) much like one would do in Excel.
Currently I have a before update event for writing new records:
[code=vb]
Private Sub Form_BeforeUpda te(Cancel As Integer)
'When a user is creating a new record the following code inserts the MonthID, YearID and
'The LocationsID. It does a Dlookup for the Locations ID when the control cboLocation is
'blank.
Dim frm As Form
Set frm = Forms!Forecast
If IsNull(frm![Binding_Percent age]) Then
MsgBox ("You need to select a Binding Percentage before you create a new record")
Cancel = True
Else: Cancel = False
End If
If Me.NewRecord Then
'If cboLocation is Not Null, grab the value from there
If Not IsNull(frm![cboLocation]) Then
JtnLocationsID = frm!cboLocation
YearID = frm!CboYear
MonthID = frm!CboMonth
Else 'Forms!Forecast ![cboLocation] is Null
'Check and see if all 3 Controls have values in them
If Not IsNull(frm![cboDivision]) And Not IsNull(frm![cboWrkReg]) And _
Not IsNull(frm![cboCreditReg]) Then 'values in all 3 Controls
JtnLocationsID = DLookup("[JtnLocationsID]", "tblLocationsMM ", "[DivisionIDFK] =" & frm![cboDivision] & _
" And [WrkRegIDFK] =" & frm![cboWrkReg] & " And [CreditRegIDFK] =" & _
frm![cboCreditReg])
YearID = frm!CboYear
MonthID = frm!CboMonth
Else
'no value in [cboLocation], and 1 or more values are missing in [cboDivision],
'[cboWrkReg], or [cboCreditReg]
MsgBox "1 or more values are missing in"
End If
End If
End If
End Sub
[/code]
I played around and discovered that I could, using the mouse, right click in one of the rows and select “copy” and then right click in the last row (the new record line) and select “paste”. Actually this was pointed out to me by one of the people I am working with. What happens though, is that the paste action does not take and it creates a “blank” record of which I can then right click in that row (the newly created “blank” one) and paste again the info. Then it works. I say “blank” because it actually did create a record on my table with the YearID, MonthID, & JtnLocationsID via the above mentioned code. These are fields that are not in the displayed rows, hence why I created the code to write new records to the table.
Given the copy and paste mindset of my end user what would be the best approach to easily satisfy their desire to not have to rekey much of the information that is already in previously displayed rows? I am relatively new at this so don’t know what the best solution. One thing to mentioned is that this particular table does not have any fields where duplicates are not allowed. I guess that is one less issue to deal with.
Does anybody have ideas on how they would approach this?
Thanks,
Keith :-)
Comment