Hello, I have been using access 2010 for a few weeks now and thought I was ready to try first project which was to be a db for servicing a vehicle with service details, mileage, due dates etc. However I ran into my first problem from scratch. I put a textbox in the header of a form and was hoping to use vba to insert string from a table field such as vehicle model. I found I couldn't even just insert a string into the textbox. It just does'nt show when the form opens. So I made a very tiny db to begin for the express purpose of making this happen but the string doesn't get to the textbox for some reason. If I cannot do that then there is no way of going forward.
My vba script is pretty simple and I have included a msgbox which doesn't come up so that confirms there is null entry in the textbox. Very grateful if someone could help.
Option Compare Database
Option Explicit
Dim carton As String
Private Sub Text5_AfterUpdate()
carton = "Bugger"
MsgBox "The value is" & " " & carton
Text5 = carton
If IsNull(Me.Text5.Value) Or (Me.Text5.Value = "") Then
Exit Sub
Else: MsgBox "The value is" & " " & carton
End If
End Sub
I then tried adding the following to form properties in vba:
Private Sub Form_AfterUpdate()
carton = "Bugger"
MsgBox "The value is" & " " & carton
End Sub
That also is not working so it looks like the vba just does nothing or is not even linked to the db even though I explicitly added the code to vba from the form properties. I think this is the real reason why I am missing something I don't understand how to force vba to do it's work on the form. Such a trivial but frustrating error.
My vba script is pretty simple and I have included a msgbox which doesn't come up so that confirms there is null entry in the textbox. Very grateful if someone could help.
Option Compare Database
Option Explicit
Dim carton As String
Private Sub Text5_AfterUpdate()
carton = "Bugger"
MsgBox "The value is" & " " & carton
Text5 = carton
If IsNull(Me.Text5.Value) Or (Me.Text5.Value = "") Then
Exit Sub
Else: MsgBox "The value is" & " " & carton
End If
End Sub
I then tried adding the following to form properties in vba:
Private Sub Form_AfterUpdate()
carton = "Bugger"
MsgBox "The value is" & " " & carton
End Sub
That also is not working so it looks like the vba just does nothing or is not even linked to the db even though I explicitly added the code to vba from the form properties. I think this is the real reason why I am missing something I don't understand how to force vba to do it's work on the form. Such a trivial but frustrating error.
Last edited: