Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 26th, 2007, 03:13 AM
Registered User
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Split form

Hi, This is my first post here.
I'd like to say that I'm new to VBA and am learning.
I have a text value (letters and numbers) that is my primary key (be nice) and I am having trouble switching from one form to another (same table). I know it has something to do with querying the record when Form2 opens (want Form1 to close when Form2 opens). I am stuck with this ID format so please don't slam me. I am able to do this when I add a "autonumber" to the table and use it in the forms. As I will have this ID in the table anyway and it will be unique to each record and will be used to relate several tables I hate to stick an autonumber in just to be able to do this. Below is the code I am currently using with the autonumber, any help would be appreciated.
I am using Access 2003
Thanks, DCC

Form1:
Private Sub cmdContinueReport_Click()
On Error GoTo MyErrorHandler

Me.mycheckbox = True

Dim lngID As Long
lngID = Me.ID 'Autonumber, would like to use text value
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "FORM2", , , "ID = " & lngID

MyErrorHandlerExit:
Exit Sub
MyErrorHandler:
MsgBox "Error Description: " & Err.Description & " Error Number: " & Err.Number
Resume MyErrorHandlerExit

End Sub


 
Old November 26th, 2007, 08:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there.. I don't see where is your problem.. what type of error are you receiving?? where??

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old November 26th, 2007, 08:36 PM
Registered User
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for looking, the problem was that I didn't want to have to add the autonumber field. I got it figured out today, had be trying to use the text value as a string but couldn't get it to work, discovered I had not been using the right combination of quotes.
This is working so thanks again. DCC
Dim strID As String
strID = Me.ID
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "FORM2", , , "[ID]= '" & strID & "'"





Similar Threads
Thread Thread Starter Forum Replies Last Post
To Split or Not to Split darrenb Access 2 February 8th, 2008 12:28 PM
split() darkhalf Javascript 1 October 21st, 2005 11:34 AM
Split crmpicco VB How-To 6 May 17th, 2005 04:16 AM
split crmpicco Classic ASP Basics 2 February 14th, 2005 08:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.