I have a MS Access form for data edits. A subset of the data fields very occasionally need updates at this point, but generally do not. I have hidden the controls for those fields, requiring a user to click a button to intentionally show those hidden controls. An additional wrinkle is that cases ending in "A" can not be updated here, while those ending in any other letter may be.
For the OnClick of my button I want to use an IF statement to
- (if they are on an "A" record) exclude the "A" records and open a messagebox to the user that they have to be updated on the main case form.
- (for any other records) show the fields to update.
As a last bit, when they update any of the fields, I need to set a checkbox to TRUE so that in the future the record will not be overwritten in an update query.
Private Sub btnUpDtAllegInfo_Click()
Dim Msg, Style, Title, Response
Msg = "Message to user"
Style = vbCritical
Title = "Can't update allegation A here"
' if "A" allegation, show error message
If Me.AltIntCaseNumber Like "*A" Then
Response = MsgBox(Msg, Style, Title, vbOK)
' if not "A", show the edit fields and hide the text box.
Else
Me.Location.Visible = True
Me.LocationCity.Visible = True
Me.LocationState.Visible = True
Me.ProviderName.Visible = True
Me.Site.Visible = True
Me.SiteCity.Visible = True
Me.SiteState.Visible = True
Me.SiteZip.Visible = True
Me.txtWarning.Visible = False
End If
End Sub
The field being tested is AltIntCaseNumber. The other fields are updateable except for txtWarning which is a simple set of directions reminding the user of the rules (visible by default - hidden on click). Most of what I have above is cobbled from what I've found online. The parts have all worked elsewhere in other contexts, but for some reason when I set it up this way I get a 'Run-time error 5' that I can't resolve. On debug, the "Response = MsgBox() call is highlighted.
All the suggested posts I found related to other programing approaches (C#, ASP.Net) though I feel like the resolve should be pretty simple.
Aucun commentaire:
Enregistrer un commentaire