I'm new to coding in Access but keen to learn more and would appreciate some help. Sorry if I break any forum regulations, still learning.
Here is the scenario.
We do a lot of data entry in our business, and often the next record we enter has a lot of the same values as the one you've just entered.
So I'm trying to get the 'Add New Record' button in our form to automatically pull across details from the record just entered into the new record - to save time on double entering data.
I've attached a picture of what a filled out record looks like compared to a fresh load of a record.
I've figured out how to pull across info from the main form into the new record (for example all the 'vessel, date, location' etc fields up the top of our form).
However, I'm having trouble
- Putting details into the subforms (for example the 'seagrass' form)
- Adding new rows in the subform (the seagrass form for example always has 3 records entered with the same observer)
- Also, having issues with setting the value for objects that have a space in the name.. for example the "exclude from biomass" tickbox, I always have issues trying to set the value of that box through code
Here is the code that I've come up with
Green text all works fine, red is error, blue (while it does set focus of the cursor to the 'observer' box in the seagrass form) does nothing but runs
Code:
Private Sub Command98_Click()
Dim ID As Long
Dim ObCount As Integer
ID = Site
ObCount = 0
DoCmd.GoToRecord , , acNewRec
Site = ID + 1
Date = DLookup("Date", "SITE DETAILS", "Site=" & ID)
Location = DLookup("Location", "SITE DETAILS", "Site=" & ID)
Substrate = DLookup("Substrate", "SITE DETAILS", "Site=" & ID)
Vessel = DLookup("Vessel", "SITE DETAILS", "Site=" & ID)
Heli = DLookup("Helicopter", "SITE DETAILS", "Site=" & ID)
Cam = DLookup("Camera", "SITE DETAILS", "Site=" & ID)
Gra = DLookup("Grab", "SITE DETAILS", "Site=" & ID)
Walking = DLookup("Walking", "SITE DETAILS", "Site=" & ID)
Dive = DLookup("Diver", "SITE DETAILS", "Site=" & ID)
Grass = DLookup("Seagrass", "SITE DETAILS", "Site=" & ID)
Exclude from Biomass = DLookup("Exclude from Biomass", "SITE DETAILS", "Site=" & ID) - this results in error
Seagrass.SetFocus
Do Until ObCount = 4
Observer = DLookup("Observer", "BIOMASS Ranks", "Site=" & ID)
Form.NewRecord - this errors but what I'm trying to achieve is adding a new row to this form, then I would need to know how to select and set the new 'Observer' box
ObCount = ObCount + 1
Loop
End Sub
I would really appreciate any help. Thanks in advance