move row from one table to another

yes it is a command button on the form which when pressed views the query as a report.

It doesnt show anythign when i click on it.

How can i get the form to load then insert the
[Forms]![ViewCableCardForm]![Combo29]
into the criteria of the CableInstaller field?
 
Ok, you should put Forms!ViewCableCardForm!Combo29 in as the criteria, and then save the query. It will stay in there. Then, what is the code behind your command button?
 
the vb code for the button is:

Private Sub Command32_Click()
On Error GoTo Err_Command32_Click
Dim stDocName As String
stDocName = "tblCableCardQuery"
DoCmd.OpenReport stDocName, acPreview
Exit_Command32_Click:
Exit Sub
Err_Command32_Click:
MsgBox Err.Description
Resume Exit_Command32_Click

End Sub


but even if i delete the preview button so that on the Form there is just the combo box, it still wont show anything if i click on the Form because i have
[Forms]![ViewCableCardForm]![Combo29]
in the CableInstaller Criteria.
It just loads up blank, all grey.


Edit:

I thought it was because there was no value for the combo box that it wouldnt work, so i set the combo box to a default value of 4. But still it doesnt work.
 
Are you saying that the query that the form is based on is using the criteria?
 
Are you saying that the query that the form is based on is using the criteria?
Hmm im not sure what you mean but yes the query(tblCableCardQuery) has the criteria in it under CableInstaller field.

The form(ViewCableCardForum) has the combo box(combo29), the combo box gets its data from a table(tblEmployees). when the combo box selects a name, the ID number of the employee stays in the combo box, i then want the criteria box in CableInstaller Field which is in the query(tblCableCardQuery) to have the value of whatever is in combo box(combo29). The query when opened will then only show cables that have been installed by whatever person has been selected in the combo box... because if i just put in number 4 into the criteria field it will only show cables installed by dave smith who is employee number 4 ie he has ID=4

Im not sure exactly what you mean?

The query(tblCableCardQuery) in design view has: field, table, sort, show, Criteria, Or

Under the CableInstallerField, i am puting
[Forms]![ViewCableCardForm]![Combo29]
into the criteria box.
I dont see why by puting this in it doesnt take the value from the combo box.
Because if i type in any employees number it will only show cables that that specific employee has installed.
 
Last edited:
I think that the query does not know how to dig down into the columns collection of a combo box. If you want the value in column 0, that will be the value in the box. If you want a value in another column, then what I do is place a hidden text box on the form and in the AfterUpdate event of the combo box, put code that sets the text box to the appropriate column of the selected row. Then I have the query refer to the text box.
 
I understand what you mean but using the immediate and entering
?[Forms]![ViewCableCardForm]![Combo29]
it returns the correct value.
So i dont need to specify which column it is.

If i load the form first, select a value in the comobox, then open the query in design view and enter this in the criteria box of the CableInstaller field:
[Forms]![ViewCableCardForm]![Combo29]
It works fine, i can select anything in the combo box and when i preview the query it gives me the correct data and the filter is working but....why do i need to load the form first, then enter [Forms]![ViewCableCardForm]![Combo29]
into the criteria box then save the query before it works, why will it not work with this in the criteria box all the time?:confused:
 
Hello again all. At long last i got it to work :D the code i was entering into the criteria field was wrong, it now works with this:

Like "*" & [Forms].[ViewCableCardForm].[Combo29] & "*"


I got the information from this really good website:
http://allenbrowne.com/ser-62.html

I would just like to thank everyone for there help and time especially Alisa.
Your help and time truely make this a top website.

Thanks Again
Dom
 

Users who are viewing this thread

Back
Top Bottom