Hi All,
My database consists of 40,000 AM/FM Radio Station records.
Within each record there is a FacilityID which is unique to that station, within that record I have fields for Format (Program type) and Slogan (On air Moniker).
Some stations on FM within the States have translators or repeaters on different frequencies so their main signal is extended to these areas where the main signal is poorly covered, these translators also have a facility id. I have a list that shows the main station with its facility id and with that list, it shows the other stations it re-transmitts on, this is called the Associated ID. I would like to use an update query to update the database rather than manual one record at a time.
What I want to do is enter the associated id value in a text box on a form and go and lookup under the facility id field of the parent station within the same table and return the format and the slogan field to the repeater record.
Someone on another list presented this code as follows.
Code:
Private Sub AssociatedID_AfterUpdate()
If DCount("*", "tblStations", "FacilityID=" & Me.AssociatedID) > 0 Then
Me.Format = DLookup("Format", "tblStations", "FacilityID=" & Me.AssociatedID)
Me.Slogan = DLookup("Slogan", "tblStations", "FacilityID=" & Me.AssociatedID)
Else
MsgBox "You have entered an invalid Associated ID that does not match any Facility ID", vbOKOnly, "No Updates to Format/Slogan!"
End If
End Sub
This code works fine as you type in the associated id number in the record, it does return the Format and Slogan data from the parent record as wanted.
The issue I am finding is I close down the database and come back into same of these records, its not holding the data in the format or slogan fields. I have found if I re-enter the associated id number back in the field again, all is good.
The main reason to do this is to save time. If the parent station changes its format from Country to Classic Rock, it will mean I will need to go to each record they re-transmit on and update the format there, the dlookup expression will update these records as the parent record is updated.
Is there another solution to the above that once the associated id is entered it will present the data in format and slogan when viewing the record at a later date?
I hope this all makes sense!