DoCmd.OpenForm

G

Guest

This is my first data base design And I have problem with DoCmd.OpenForm
command
I have a table Car order Table (OrderID -- primary key.) I created form
“Order ID by Customer†where I can look at all orders based on a customer. On
that form I created “OrderID Subform†that is showing a few detail fields
regarding specific order. I would like to select specific orderid on a
subform and would like to go to another form called “Car Order Form†that
would show me all details regarding this order. I created command button
(View Order Detail )and assigned code
Private Sub ExpenseReport_Click()
On Error GoTo Err_ExpenseReport_Click
If IsNull(Me![CustomerID]) Then
MsgBox "Enter customer before entering customer report."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "Car Order Form", , , "[OrderID] = " & [OrderID], ,
acDialog
End If

Exit_ExpenseReport_Click:
Exit Sub

Err_ExpenseReport_Click:
MsgBox Err.Description
Resume Exit_ExpenseReport_Click
End Sub

I am receiving error message when highlighting specific order and clicking
on View Order Detail command button in line:
DoCmd.OpenForm "Car Order Form", , , "[OrderID] = " & [OrderID], , acDialog
Syntax error (missing operator) in query expression ‘[OrderID] = ‘
OrderID primary key is set as AutoNumber.
Thanks for your help
 
G

Guest

I just got this to work for me. NUM is the name of the box on my form that
contains the primary key - you can even have it hidden if you want.
m_ACCOUNT_NUM is the name of the field in your table. Try this:

Private Sub cmdEditRecord_Click()
Dim strFormName As String
Dim strRecordID As String

strFormName = "frmGMI_UpdateRecord"
strRecordID = "m_ACCOUNT_NUM=" & NUM
DoCmd.OpenForm strFormName, , , strRecordID

End Sub
 
G

Guest

Private Sub ExpenseReport_Click()
Dim strFormName As String
Dim strRecordID As String

strFormName = "Car Order Form"
strRecordID = "OrderID=" & OrderID
DoCmd.OpenForm strFormName, , , strRecordID

End Sub

Same error message

leesah said:
I just got this to work for me. NUM is the name of the box on my form that
contains the primary key - you can even have it hidden if you want.
m_ACCOUNT_NUM is the name of the field in your table. Try this:

Private Sub cmdEditRecord_Click()
Dim strFormName As String
Dim strRecordID As String

strFormName = "frmGMI_UpdateRecord"
strRecordID = "m_ACCOUNT_NUM=" & NUM
DoCmd.OpenForm strFormName, , , strRecordID

End Sub

Greg said:
This is my first data base design And I have problem with DoCmd.OpenForm
command
I have a table Car order Table (OrderID -- primary key.) I created form
“Order ID by Customer†where I can look at all orders based on a customer. On
that form I created “OrderID Subform†that is showing a few detail fields
regarding specific order. I would like to select specific orderid on a
subform and would like to go to another form called “Car Order Form†that
would show me all details regarding this order. I created command button
(View Order Detail )and assigned code
Private Sub ExpenseReport_Click()
On Error GoTo Err_ExpenseReport_Click
If IsNull(Me![CustomerID]) Then
MsgBox "Enter customer before entering customer report."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "Car Order Form", , , "[OrderID] = " & [OrderID], ,
acDialog
End If

Exit_ExpenseReport_Click:
Exit Sub

Err_ExpenseReport_Click:
MsgBox Err.Description
Resume Exit_ExpenseReport_Click
End Sub

I am receiving error message when highlighting specific order and clicking
on View Order Detail command button in line:
DoCmd.OpenForm "Car Order Form", , , "[OrderID] = " & [OrderID], , acDialog
Syntax error (missing operator) in query expression ‘[OrderID] = ‘
OrderID primary key is set as AutoNumber.
Thanks for your help
 
G

Guest

One more q.
OrderID is aprimary key for car oder table. However i place order ID filed
on a subform called Order ID Subform. Do i have to mention subform name in
this code?
Private Sub ExpenseReport_Click()
Dim strFormName As String
Dim strRecordID As String

strFormName = "Car Order Form"
strRecordID = "OrderID=" & OrderID
DoCmd.OpenForm strFormName, , , strRecordID

Where and how. Thanks

Greg said:
Private Sub ExpenseReport_Click()
Dim strFormName As String
Dim strRecordID As String

strFormName = "Car Order Form"
strRecordID = "OrderID=" & OrderID
DoCmd.OpenForm strFormName, , , strRecordID

End Sub

Same error message

leesah said:
I just got this to work for me. NUM is the name of the box on my form that
contains the primary key - you can even have it hidden if you want.
m_ACCOUNT_NUM is the name of the field in your table. Try this:

Private Sub cmdEditRecord_Click()
Dim strFormName As String
Dim strRecordID As String

strFormName = "frmGMI_UpdateRecord"
strRecordID = "m_ACCOUNT_NUM=" & NUM
DoCmd.OpenForm strFormName, , , strRecordID

End Sub

Greg said:
This is my first data base design And I have problem with DoCmd.OpenForm
command
I have a table Car order Table (OrderID -- primary key.) I created form
“Order ID by Customer†where I can look at all orders based on a customer. On
that form I created “OrderID Subform†that is showing a few detail fields
regarding specific order. I would like to select specific orderid on a
subform and would like to go to another form called “Car Order Form†that
would show me all details regarding this order. I created command button
(View Order Detail )and assigned code
Private Sub ExpenseReport_Click()
On Error GoTo Err_ExpenseReport_Click
If IsNull(Me![CustomerID]) Then
MsgBox "Enter customer before entering customer report."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "Car Order Form", , , "[OrderID] = " & [OrderID], ,
acDialog
End If

Exit_ExpenseReport_Click:
Exit Sub

Err_ExpenseReport_Click:
MsgBox Err.Description
Resume Exit_ExpenseReport_Click
End Sub

I am receiving error message when highlighting specific order and clicking
on View Order Detail command button in line:
DoCmd.OpenForm "Car Order Form", , , "[OrderID] = " & [OrderID], , acDialog
Syntax error (missing operator) in query expression ‘[OrderID] = ‘
OrderID primary key is set as AutoNumber.
Thanks for your help
 
G

Guest

If the field OrderID is on the Form "Order ID by Customer"

Try this:

strRecordID = "OrderID = Forms!Order ID by Customer!OrderID"




Greg said:
Private Sub ExpenseReport_Click()
Dim strFormName As String
Dim strRecordID As String

strFormName = "Car Order Form"
strRecordID = "OrderID=" & OrderID
DoCmd.OpenForm strFormName, , , strRecordID

End Sub

Same error message

leesah said:
I just got this to work for me. NUM is the name of the box on my form that
contains the primary key - you can even have it hidden if you want.
m_ACCOUNT_NUM is the name of the field in your table. Try this:

Private Sub cmdEditRecord_Click()
Dim strFormName As String
Dim strRecordID As String

strFormName = "frmGMI_UpdateRecord"
strRecordID = "m_ACCOUNT_NUM=" & NUM
DoCmd.OpenForm strFormName, , , strRecordID

End Sub

Greg said:
This is my first data base design And I have problem with DoCmd.OpenForm
command
I have a table Car order Table (OrderID -- primary key.) I created form
“Order ID by Customer†where I can look at all orders based on a customer. On
that form I created “OrderID Subform†that is showing a few detail fields
regarding specific order. I would like to select specific orderid on a
subform and would like to go to another form called “Car Order Form†that
would show me all details regarding this order. I created command button
(View Order Detail )and assigned code
Private Sub ExpenseReport_Click()
On Error GoTo Err_ExpenseReport_Click
If IsNull(Me![CustomerID]) Then
MsgBox "Enter customer before entering customer report."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "Car Order Form", , , "[OrderID] = " & [OrderID], ,
acDialog
End If

Exit_ExpenseReport_Click:
Exit Sub

Err_ExpenseReport_Click:
MsgBox Err.Description
Resume Exit_ExpenseReport_Click
End Sub

I am receiving error message when highlighting specific order and clicking
on View Order Detail command button in line:
DoCmd.OpenForm "Car Order Form", , , "[OrderID] = " & [OrderID], , acDialog
Syntax error (missing operator) in query expression ‘[OrderID] = ‘
OrderID primary key is set as AutoNumber.
Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top