Link to home
Start Free TrialLog in
Avatar of gigifarrow
gigifarrow

asked on

Form not getting an error message but not populating form

I have a form that populates another form based on the serial number. The serial number in the main form is an unbound text box named Text128. I am not getting any error but it is not populating the other form named frmRework/InspectionSheet. Do I need to put the name of the form it is populating too? If so, How do I do that?

Private Sub Location_AfterUpdate()
MsgBox "Please Enter Rework Information."
[Forms]![frmMODInfoKit]![Text128] = Me.[Vehicle Serial Number]
DoCmd.OpenForm "frmRework/InspectionSheet"
 


End Sub
Avatar of Barry Cunney
Barry Cunney
Flag of Ireland image

Dim strCriteria$

strCriteria$ = [KeyFieldOnFormBeenOpened] = Me![Vehicle Serial Number]

DoCmd.OpenForm frmRework/InspectionSheet, , ,strCriteria$
Avatar of Scott McDaniel (EE MVE )
Also note that if the "Serial Number" field on the form being opened is a Text value, you'll have to do this:

DoCmd.OpenForm "YourFormName", , , "YourFieldName='" & Me.[Vehicle Serial Number] & "'"
Avatar of gigifarrow
gigifarrow

ASKER

Thanks for all the help! Here is what I used first:

Private Sub Location_AfterUpdate()
MsgBox "Please Enter Rework Information."
Dim strCriteria$
strCriteria$ = [Text128] = Me![Vehicle Serial Number]
DoCmd.OpenForm frmRework/InspectionSheet , , , strCriteria$

Got an error Variable not defined with frmRework/InspectionSheet highlighted as the error.

So then I tried this with the change below on the DoCmd:
Private Sub Location_AfterUpdate()
MsgBox "Please Enter Rework Information."
Dim strCriteria$
strCriteria$ = [Text128] = Me![Vehicle Serial Number]
DoCmd.OpenForm "frmRework/InspectionSheet", , , strCriteria$
 End Sub

Didn't get an errror but doesnt populate the form.
I also tiried this,

 DoCmd.OpenForm "frmRework/InspectionSheet", , , "Text128 ='" & Me.[Vehicle Serial Number] & "'"

I got a prompt to  enter Parameter value showing Text128





I do have a questio about the code I know this is not part of the question but I have never taking visual basic, just wanted to know what , , , means and what does the $ do or mean?



 InspectionSheet, , ,strCriteria$

doesnt this say add this & "'"  to the field serial number?

 & "'"



xt128
,,,,  are like placeholders for optional parameters that are not supplied

$ is a Type Declaration character for the String Type
So
Dim sName$
is shorthand for
Dim sName As String
I got a prompt to  enter Parameter value showing Text128
That generally means that you've not spelled the name of the control or field correctly - and in fact, if you're not naming your controls anything meaningful (like txUserName instead of Text128) then you'll find a difficult time ahead.

You should always rename your controls to reflect their actual purpose. If I add a Textbox to my form where I expect the user to enter their UserName, for example, I would name it something like "txUserName" or "txbUserName" perhaps. Leaving those names as "Text128" is a very good way to get confused.
LSMConsulting I changed the text name thanks for that suggetion however now I am getting syntax error (Missing operator) in query expression Vehicle Serial Number = '2AD365"
This is what I have:

 DoCmd.OpenForm "frmRework/InspectionSheet", , , "Vehicle Serial Number ='" & Me.[Vehicle Serial Number] & "'"


And thanks  for clarifying the code for me BCUNNEY!
I am getting syntax error (Missing operator) in query expression Vehicle Serial Number = '2AD365"
This is what I have:

 DoCmd.OpenForm "frmRework/InspectionSheet", , , "Vehicle Serial Number ='" & Me.[Vehicle Serial Number] & "'"

I changed it again  the comma and prarenthese to "'"Vehicle Serial Number ='" dont get an error but doesnt populate other form
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial