Forms- getting last instant of data and putting it into next, in a one to many relationship using VBA

farmerscott

Well-known Member
Joined
Jan 26, 2013
Messages
824
Office Version
  1. 365
Platform
  1. Windows
Hi Guys,

Using Access 2007 with low to intermediate skills in VBA.

I have a situation where I enter a lot of data that often repeats itself, but I can't "hard wire" the values. I hope that makes sense.

I want to be able to click over (on the many side of the form) and have a checkbox that says "Do you want to repeat the values?" The values would be pasted in and I could then make any minor adjustments. The start of the code might look like-

Code:
Private Sub Check58_Click()
Dim DateFilled As Date
Dim DateSprayed As Date

If Check58 = True Then
DateFilled = Date_Filled.Value 'get last instance from previous entry.
DateSprayed = Date_Sprayed.Value 'get last instance from previous entry.

End If
End Sub

Any thoughts on how you might approach this? I am thinking I can save the data (in VBA) and then paste it into the new/empty form.

cheers

FarmerScott
 
Guys,

the code below is working well. The after update change event on the form seemed to work the best option. I put the background colour in as a visual effect.

Code:
Private Sub Form_AfterUpdate()
Me![Date1].DefaultValue = """" & Me![Date2].Value & """"
        Me![Date1].BackColor = RGB(0, 255, 0)
        Me![Start Time].DefaultValue = """" & Me![End Time].Value & """"
        Me![Start Time].BackColor = RGB(0, 255, 0)
        Me![Start Temp].DefaultValue = """" & Me![End Temp].Value & """"
        Me![Start Temp].BackColor = RGB(0, 255, 0)
End Sub

cheers

FarmerScott
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,221,692
Messages
6,161,327
Members
451,697
Latest member
pedroDH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top