Form to select name and launch new form

Steve27597

New member
Local time
Today, 03:10
Joined
Feb 25, 2014
Messages
8
Hello everyone!
I am working on an access database that is a meeting registration database. It is relatively simple in concept:
You can search by Name, Phone, or Account Number and then mark the person as registered.

What I am trying to create is an enhanced search by name. I have created a simple form in datasheet format so that if I search by last name I will probably get a list of names with that last name.
I want to be able to select the name I want, either by double click or highlite and press a button, and then it launches my form that I created for the account lookup / registration.
The account form runs a query that prompts for an account number and displays that account.

I am unable to figure out how to launch the second form passing the selected record's account number.

I hope I don't sound too confusing. I would love some advice as I am not even close to being an access or vba expert.

Thank you,
Steve :banghead:
 
Thanks pbaldy for the reply.
That sounds exactly like what I want but I keey getting a Compile Error: Syntax error.
Here is my code:

Private Sub Account_DblClick(Cancel As Integer)
Dim SelAcct As String
SelAcct = Me.Account
Debug.Print "TEST"
Debug.Print SelAcct
DoCmd.OpenForm(Form_AccountFormBlank,,,"Account = " & SelAcct)
End Sub

I think it is erroring on the DoCmd line because that is what it has highlighted in blue when it stops. I added the debug.print statements to see if I had a value in teh SelAcct variable, but it does not display any debugging that I can see. So is it even getting that far?

Thanks again,
Steve
 
The form is a string (and if it's a compile error you wouldn't get to the debug lines). Try

DoCmd.OpenForm "Form_AccountFormBlank",,,"Account = " & SelAcct

or this if this is the form name:

DoCmd.OpenForm "AccountFormBlank",,,"Account = " & SelAcct
 
THANK YOU! Definitely getting closer. I am seeing my debug.print statements execute and I see that I have the account number selected.

Now I am getting a Run-time error '3464', Data type mismatch in criteria expression. It is getting hung up on the DeCmd.OpenForm line. Here is the current line:

DoCmd.OpenForm "AccountFormBlank", , , "Account = " & SelAcct

Thanks again,
Steve
 
Did you notice in the link that different data types require different syntax? What is the data type of the Account field?
 
Thanks one more time pbaldy. I figured out by looking at some other posts that I was missing the quotes in the criteria section. Final code looks like this:

Dim SelAcct As String
SelAcct = Me.Account
DoCmd.Close
DoCmd.OpenForm "AccountFormBlank", , , "Account = '" + SelAcct + "'"

Thanks for your help.
-Steve
 

Users who are viewing this thread

Back
Top Bottom