Form opens blank, is it corrupt?

Do a new query on tblTripDetails and only show the records where the customerID = the customer id on form a. The use it as a source for form b.
 
Set the recordsource of form b on a query simular to this one:
 

Attachments

  • query_example_1.gif
    query_example_1.gif
    11.5 KB · Views: 131
hi

i'm actually using all the info in the tables (so table.* or whatever) so you can't use criteria - when i do it all individually, it doesn't work either.

Please, does anyone know why this is happening? I'm really stuck, and the code is exactly the same as the training form which works perfectly :(

Please, any suggestions?

Thank you

Eddie
 
Sharky II said:
i'm actually using all the info in the tables (so table.* or whatever) so you can't use criteria - when i do it all individually, it doesn't work either.

Don't bind a table to a form. Make a query of your table and bind that.
 
makes no difference :(

what on earth would cause this? like i say, used to work fine before

thanks guys
 
And change that code to this:

Code:
Private Sub TrainingButton_Click()
    On Error GoTo Err_TrainingButton_Click

    If DCount("*", "qryExample", "CustomerID = " & Me.CustomerID) = 0 Then
        MsgBox "No records found.", vbExclamation
    Else
        DoCmd.OpenForm "frmTrainingDetails", , , , "[CustomerID]= " & Me.[CustomerID]
    End If

Exit_TrainingButton_Click:
    Exit Sub

Err_TrainingButton_Click:
    MsgBox Err.Description
    Resume Exit_TrainingButton_Click
    
End Sub
 
Sharky II said:
makes no difference :(

It wasn't meant to. That was a best practice issue. You DON'T bind a table to a form; always bind queries.
 
oh right, that's great cheers.

unfortunately i don't want the pop up to come up to inform me of no new records - but instead i want a form with blank fields to come up to allow me to add a new record, like it used to.

many thanks for your advice, i'll be sure to follow your example in the future

cheers mate
 
Just change the query in bold to the name of your query.

Code:
Private Sub TrainingButton_Click()
    On Error GoTo Err_TrainingButton_Click

    If DCount("*", "[b]qryExample[/b]", "CustomerID = " & Me.CustomerID) = 0 Then
        DoCmd.OpenForm "frmTrainingDetails", , , , acFormAdd

    Else
        DoCmd.OpenForm "frmTrainingDetails", , , "[CustomerID]= " & Me.[CustomerID], acFormEdit
    End If

Exit_TrainingButton_Click:
    Exit Sub

Err_TrainingButton_Click:
    MsgBox Err.Description
    Resume Exit_TrainingButton_Click
    
End Sub
 
hi

your way is very slick - i noticed what the problem was elsewhere though.

there are three tables (that are relevant to this) - tblCustomer, tblTripDetails and tblTrips.

The tripDetails table was the 'joining' table, to facilitate a many to many relationship - but somehow the TripID in the trips table was not a primary key any more - don't ask me how that happened! I deleted teh links and relinked them and it now works as it did. I'm now going back and changing the forms to queries, like you advised - thanks for that mate.

Cheers

Eddie
 

Users who are viewing this thread

Back
Top Bottom