Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 10-12-2018, 10:40 PM   #1
toumack
Newly Registered User
 
Join Date: May 2011
Location: Montréal, Québec
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
toumack is on a distinguished road
Open a form from a field in a specific table

I have a table named "JewelryStyles" in that table I have 2 text field that contains names of form I want to open using VBA at a specific point, in my recordset, I have the name of form, so what should be the command to open that form from an rst?

Image:



Here is the code so far:
Code:
Private Sub STYID1_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Dim strSQL1 As String
strSQL1 = "SELECT JewelryStyles.StylesID, JewelryStyles.JewelryStyles, JewelryStyles.Styles, JewelryStyles.OrdreTri, JewelryStyles.FormForSizes, JewelryStyles.FormForColors  FROM JewelryStyles WHERE JewelryStyles.OrdreTri=1 ORDER BY JewelryStyles.OrdreTri"
Set rst = CurrentDb.OpenRecordset(strSQL1, dbOpenDynaset, dbSeeChanges)

Me.StyleCode = rst![JewelryStyles]

rst.Close
dbs.Close
Set rst = Nothing
Set dbs = Nothing

DoCmd.OpenForm rst!FormForSizes

toumack is offline   Reply With Quote
Old 10-12-2018, 11:12 PM   #2
arnelgp
Registered User
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 6,712
Thanks: 55
Thanked 2,133 Times in 2,044 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Open a form from a field in a specific table

Private Sub STYID1_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Dim strSQL1 As String

Dim strForm As String
strSQL1 = "SELECT JewelryStyles.StylesID, JewelryStyles.JewelryStyles, JewelryStyles.Styles, JewelryStyles.OrdreTri, JewelryStyles.FormForSizes, JewelryStyles.FormForColors FROM JewelryStyles WHERE JewelryStyles.OrdreTri=1 ORDER BY JewelryStyles.OrdreTri"
Set rst = CurrentDb.OpenRecordset(strSQL1, dbOpenDynaset, dbSeeChanges)

Me.StyleCode = rst![JewelryStyles]
strForm=rst!FormForSizes & ""
rst.Close
dbs.Close
Set rst = Nothing
Set dbs = Nothing

if strForm <> "" Then
DoCmd.OpenForm strForm
End If
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
The Following User Says Thank You to arnelgp For This Useful Post:
toumack (10-13-2018)
Old 10-13-2018, 11:45 PM   #3
toumack
Newly Registered User
 
Join Date: May 2011
Location: Montréal, Québec
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
toumack is on a distinguished road
Re: Open a form from a field in a specific table

Thanks, your code will be useful if there is no name in the table for the form size, than continue with the color form.
Super!

toumack is offline   Reply With Quote
Old 10-13-2018, 11:54 PM   #4
arnelgp
Registered User
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 6,712
Thanks: 55
Thanked 2,133 Times in 2,044 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Open a form from a field in a specific table

you mean if the field FormForSizes is blank, use the field FormForColors?



strForm=rst!FormForSizes & ""
if strForm = "" then strForm = rst!FormForColors & ""
rst.Close
dbs.Close
...
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
The Following User Says Thank You to arnelgp For This Useful Post:
toumack (10-14-2018)
Old 10-14-2018, 12:51 AM   #5
toumack
Newly Registered User
 
Join Date: May 2011
Location: Montréal, Québec
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
toumack is on a distinguished road
Re: Open a form from a field in a specific table

I will test it tomorrow, it is 5 o'clock in the morning here… thanks again

Claude

toumack is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Inserting specific field from a form into a specific table Naqibullah Queries 9 02-13-2017 03:03 AM
Hyperlink field in table-use form button to open for a specific record StevK Forms 0 04-07-2014 09:52 PM
read the data of a specific row & a specific field in a table huanghang111 Tables 3 08-02-2013 01:00 PM
Open Form to Specific Field depawl Forms 1 08-15-2007 07:18 PM
Open Form and have it Alphabetized by specific field, but different field each time.. brian0721 Forms 2 06-09-2004 12:00 PM




All times are GMT -8. The time now is 05:14 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World