Access 2003: DoCmd.OpenForm is not working for me

It opens up a dialog box.

DoCmd.OpenForm (frmActionUser,acNormal,,,acFormReadOnly,acDialog,)

I know I'm missing something because it generates the following error: "Compile Error: Expected Expression"

For reference, When the button is clicked, a box appears where the user has to input a uniqe Tracking ID. If the Tracking ID does not match any in the background table, it returns an error message.

If it is correct, a dialog box opens for the Tracking ID with pertinent data. The Tracking ID's are always going to be numerical. Here's thefull code (hopefully...

Sponsored Links:

Related Topics

DoCmd.OpenForm Syntax Error
I think I have been staring at this too long. Can somebody tell me why it's not working?
DoCmd.OpenForm "frmListProcDefaults", , , "ProcName= & Me.ProcName"

set focus specific form
I have a problem with regards with the setfocus of certain form. I have a command button that will open several forms and once open I want to setfocus it in "Purchase Requisition" form. please see code below

Private Sub Login_Click()
Dim Password As Variant
Password = DLookup("Password", "Users", "UserID = '" & Me.txtUserID & "' ")

If Nz(Password, "") = Me.txtpassword Then

DoCmd.OpenForm "Purchase Requisition"
DoCmd.OpenForm "Purchase Order"
DoCmd.OpenForm "Supplier Information"
DoCmd.OpenForm "Archive"
DoCmd.OpenForm "Others"

MsgBox "Incorrect user ID or password"
End If

End Sub

DoCmd.OpenForm Expected
I'm attempting to pull a row of data in a table by opening a separate form using the DoCmd.OpenForm command. I have raw data that is copied into a text box and the code pulls out the time, tech and customer.

That all works fine but the OpenForm is failing me! I CAN run the code as follows:

What actually happens at docmd.openform

Im relatively new to Access but have some background in VBA programming.

Currently im dealing with a relatively large Database (Access File size currently at 1GB) wich of course makes computations very slow.

Im now trying to speed things up a bit and was wondering what actually happens at the Docmd.openform command. I dont mean "The form is opened" but im wondering what happens in the background.
The problem is that some of my forms take extremely long to execute this single line, so I think there is something else happening besides the simple "form opening" task.

So if anybody knows how to deal with speed issues on docmd.openform or can explain what actually is checked/computed on this command, please answer!

Thanks in advance for all responses and excuse my english, im not a native speaker.

Argument not optional
I am writing some code for a database button but the error message argument not optional appears, saying that my OpenForm is incorrect.

Private Sub Command47_Click()
DoCmd.OpenForm.[tbljobs main]
DoCmd.GoToRecord , , acNewRec
DoCmd.ApplyFilter "jobs form search

Simple code im derping on :P
Private Sub Command24_Click()
If IsNull(Me.Text1) Then
MsgBox "You have not filled all boxes." & vbCrLf & _
"Do you want to continue?", vbYesNo, "Edit Visit Report"
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm "HomePage"
End If
Dim Msg As VbMsgBoxResult
If Msg = vbYes Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm "HomePage"
End If
End Sub

Pretty self explanatory its not working when I press yes, when it should save and open "HomePage"

DoCmd.OpenForm method - go straight to EOF ( recordset ) ?
Can I use the OpenForm method, to open my form based on a query, and go IMMEDIATELY to EOF I.e. Here's my current statement, with just the query name to qualify it.

DoCmd.OpenForm "frmClients", , qry1

DoCmd.CopyObject Not working
I am trying to copy a table (structure and data) from my application to another database using the DoCmd.CopyObject method, but it is not working. Here is my code:

DoCmd.CopyObject "C:\iHaunt\Resources\Update.accdb", "tblParameters", acTable, "tblParameters"
DoCmd.OpenForm "frmLogin1", acNormal
DoCmd.Close acForm, Me.Name

I do not get an error when this code runs and it opens the form "frmLogin1" and closes the current form just fine. But when I go to the other database, the table is not there. Does the other database need to be open?

I've also tried this with DoCmd.TransferDatabase, and that does not work either

OpenArgs not working
I have a subform (SubFrm_Warnings) which I need to appear according to which company record is open on the form. I have used OpenArgs on the DoCmd.OpenForm to set the companyref / ID number - this is working fine. I have now realised that although the correct company ID is now being set, the actually text box which contains any warnings is not linking to that company ID?

I know I must have to link this somehow. The forms involved are Frm_Search (where the DoCmd.OpenForm is); Frm_Company (which is the main form which includes all the company info) and SubFrm_Warnings (which is to appear on open of the Company form should there be any warnings for that particular company.

I have attached the database and posted the relevant code below...

DoCmd.TransferSpreadsheet acImport xlsx format from MS Access 2003
In my machine I have Access 2003 and Excel 2010. Intially I have below code to import the 2003 spreadsheet into a the table in MS Access 2003.

DoCmd.TransferSpreadsheet acImport, 8, TblNm, FileN, True, "A1:S65536"

DoCmd.TransferSpreadsheet acImport, 10, TblNm, FileN, True, "A1:S65536"

It does not work I have the Microsoft Excel 14.0 object library selected in the references. I know using of '10' is not working because I am still using MS Access 2003.

Is there any way I can import the 2010 format excel spreadsheet to Access 2003?

Runtime Error 2501 - openform action was canceled
Should be relatively simple one this, but its just not working.
We've upgraded from 2003 to 2007 in our office, and have many links to reports that need to be printed. The code is fairly simple:

DoCmd.OpenReport "RiskAssess", acViewNormal

Trouble is I get the "Runtime error 2501 - openform action was canceled" error. Double clicking on the guilty report in the navigation gives the following error

"The expression On Open you entered as the event property setting produced the following error: A problem occurred while Microsoft Office Access was communicating with the OLE server or ActiveX Control"

This now occurs for all reports in the database.

Can anyone shed some light as to why our once-working reports now do not work? I've checked the syntaz and apparently the command shouldn't be any different

i need a docmd.openform code
I need a fully docmd.openform command with where statement
Form name : repairs
Query name : qCustomers
Field name : customer name (i want to open form with all the records refer to a single customer

DoCmd OpenForm Filter?????
I'm trying to open a form which will only show records where the CardNumber has not been entered, im using the below code but its openning the form and filtering ALL records? any ideas.

Private Sub Command9_Click()

DoCmd.Close acForm, "FrmFuelCardManagement", acSavePrompt
DoCmd.OpenForm "FrmFuelCard", acNormal, , IsNull("[TblFuelCard]![CardNumber]"), acFormEdit, acWindowNormal

Simple Nav Form Code Not Working
I have a form with an unbound text box called SSN. I want user to enter a Social Security Number there and click a button which runs the following:

DoCmd.OpenForm "frmDropStudents", , , "[SocialSecurity] = " & [SSN]

frmDropStudents is opening as "filtered" showing a blank record.

This doesn't work either (same result as above):
DoCmd.OpenForm "frmDropStudents", , , "[SocialSecurity] = " & Me.SSN

SOS with this VBA
If Not IsNull(Me.lst3month.Column(0)) Then
DoCmd.OpenForm "frmReviewDetails3MONTHS", , , "EMPLOYEEREVIEWID = " & Me.lst3month Else
DoCmd.OpenForm "frmReviewDetails3MONTHS", , , "EMPLOYEEID = " & Me.lst3month End If End Sub

keeps giving me a missing operator on the "DoCmd.OpenForm "frmReviewDetails3MONTHS", , , "EMPLOYEEREVIEWID = " & Me.lst3month" line.

all I want is to open a record using a filter if the listbox row 0 is null, am I doing this right at all

Accessing DoCmd OpenForm values from within a form
When one uses the DoCmd OpenForm method there are certain parameters that can be given, including a DataMode value.

Is there any way in which any of these parameters/values can be accessed from within a form as, for example, either a form or application property or parameter when the form is either being opened or loaded?

using Environ code in Access 2007 to open up a specific form
so I am fairly new at programming and so far have been able to write basic codes but I am having a bit of trouble with this one.
My intent is this:
When someone opens up the database, I want to derive their network ID and compare it to my USERNAME table that has the access levels and the facility they are assigned to. My goal is to write code to where when they open up the database the code will only pull up the switchboard for their own facility (and facility ID is tied to an ID Number)
Here is my script with just three facilities and I know I am missing a lot of pieces to this, so any help would be much appreciated.

If Nz(DLookup("[Facility]", "Username", "[Pnumber]'" & Environ("Username") & "'"), "") = "" Then
SetFocus.UserName (Facility)

If "Facility" = 1 Then
DoCmd.OpenForm "AME_Switchboard"
ElseIf "Facility" = 2 Then
DoCmd.OpenForm "CED_Switchboard"
ElseIf "Facility" = 3 Then
DoCmd.OpenForm "CAS_Switchboard"

vba code not working with combobox
Im having a problem with my login page. I have a simple form with username and password. I used to have the username as a textbox, and the below code worked fine, replacing combo with username, but I decided I wanted a dropdown for the usernames so I deleted the textbox and created a combobox (named combo) but now I always get the else statement MsgBox "Incorrect Login Details Please Try Again" can someone tell me where im going wrong.

Private Sub Command7_click()
If combo = "Dean Robinson" And Password = "hollie" Then
MsgBox "Welcome Dean", vbInformation, "PDA TRACKING"
DoCmd.OpenForm "Main Menu"
ElseIf combo = "Robert Curley" And Password = "Password" Then
MsgBox "Welcome Rob", vbInformation, "PDA TRACKING"
DoCmd.OpenForm "Main Menu"
ElseIf combo = "Colin Rushbrooke" And Password = "Password" Then
MsgBox "Welcome Colin", vbInformation, "PDA TRACKING"
DoCmd.OpenForm "Main Menu"
MsgBox "Incorrect Login Details Please Try Again

opening a form using a listbox with different criteria
what's the best way to open a form using a listbox? but thing is, I need it to open when the column 0 is null, it will open or filter the record using column 1?

I tried this but is not working.

Private Sub lst3month_DblClick(Cancel As Integer) If IsNull(Me.lst3month.Column(0)) Then
DoCmd.OpenForm "frmReviewDetails3MONTHS", , , "EMPLOYEEID = " & Me.lst3month.Column(7) Else
DoCmd.OpenForm "frmReviewDetails3MONTHS", , , "EMPLOYEEREVIEWID = " & Me.lst3month.Column(0) End If End Sub

docmd.openform Invalid database object reference
I have a problem and I hope you will agree to help me.

After modifying database links (front end to new backend),
one form does not open and generated reference error 3276.

I open the form by clicking on tree control node.
but It does not open directly from DB window.

but, If I compact & Repair the file it opens correctly.

What should I do in order to ovoid this error ?

Private Sub menuTree_Click()
Dim strcrit As String
stricrit = menuTree.SelectedItem.Key
DoCmd.OpenForm stricrit End Sub