Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / July 2005

Tip: Looking for answers? Try searching our database.

Open Form and get record.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
StevenIpek. - 04 Jul 2005 02:42 GMT
I have written the following code (I am new at this so bear with me Please).
Basically I want to first Close the form "Bibliotheca" and then reopen it
showing the record that it was on before it closed. When I run it it tells me
"Mismatch", the field BookID is a number field so I can't understand why it
wont accept it.

I hope that someone can help me.

Private Sub Close_Edition_Number_Form_Click()
On Error GoTo Err_Close_Edition_Number_Form_Click

   Dim stDocName As String
   Dim stLinkCriteria As String
   Dim stMyName As String
   Dim intBookNum As Integer
   
   
   stMyName = "Edition"
   stDocName = "Bibliotheca"
   intBookNum = "Bibliotheca!BookID"
   
If Len("" & stMyName) < 1 Then
   DoCmd.CancelEvent
Else
   
   DoCmd.Save
   DoCmd.Close acForm, stDocName
   DoCmd.OpenForm stDocName, , , "BookID = intBookNum"
   DoCmd.Close acForm, stMyName

End If

Exit_Close_Edition_Number_Form_Click:
   Exit Sub

Err_Close_Edition_Number_Form_Click:
   MsgBox Err.Description
   Resume Exit_Close_Edition_Number_Form_Click
   
End Sub

Steven.
Marshall Barton - 04 Jul 2005 03:20 GMT
>I have written the following code (I am new at this so bear with me Please).
>Basically I want to first Close the form "Bibliotheca" and then reopen it
[quoted text clipped - 24 lines]
>    DoCmd.Close acForm, stDocName
>    DoCmd.OpenForm stDocName, , , "BookID = intBookNum"
[snip]

I think you need to change two lines

    intBookNum = FormsBibliotheca!BookID

and

    DoCmd.OpenForm stDocName, , , "BookID = " & intBookNum

Signature

Marsh
MVP [MS Access]

StevenIpek. - 04 Jul 2005 04:34 GMT
Thank you for having replied so promptly Marshall,
I have changed the two lines, unfortunately a message box comes up with
"Object required", is there something else I can do?

> >I have written the following code (I am new at this so bear with me Please).
> >Basically I want to first Close the form "Bibliotheca" and then reopen it
[quoted text clipped - 33 lines]
>
>     DoCmd.OpenForm stDocName, , , "BookID = " & intBookNum
Marshall Barton - 04 Jul 2005 18:05 GMT
Stupid fingers can't type.  I left out an exclamation mark.

    intBookNum = Forms!Bibliotheca!BookID
Signature

Marsh
MVP [MS Access]

>Thank you for having replied so promptly Marshall,
>I have changed the two lines, unfortunately a message box comes up with
[quoted text clipped - 37 lines]
>>
>>     DoCmd.OpenForm stDocName, , , "BookID = " & intBookNum
StevenIpek. - 05 Jul 2005 11:06 GMT
Hi Marshall,

Thanks for the edited version, It worked like a charm! I am sorry that I
keep on asking for help, the problem is that I have lost the book on Access
(I loand it to someone and they have lost it) so I am trying to work out what
all the commands are whilst trying to build a database for all my books, it's
comming on but very slowly, anyway thanks again for your invaluable help.

Steve.

> Stupid fingers can't type.  I left out an exclamation mark.
>
[quoted text clipped - 40 lines]
> >>
> >>     DoCmd.OpenForm stDocName, , , "BookID = " & intBookNum
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.